diff --git a/dcb-bytes-derive/Cargo.toml b/dcb-bytes-derive/Cargo.toml index f787e83..ef5f004 100644 --- a/dcb-bytes-derive/Cargo.toml +++ b/dcb-bytes-derive/Cargo.toml @@ -8,6 +8,7 @@ edition = "2018" proc-macro = true [dependencies] +dcb-bytes = { path = "../dcb-bytes" } proc-macro2 = "1.0" quote = "1.0" syn = { version = "1.0", features = ["full", "extra-traits"] } diff --git a/dcb-bytes/src/lib.rs b/dcb-bytes/src/lib.rs index db97293..b9772f5 100644 --- a/dcb-bytes/src/lib.rs +++ b/dcb-bytes/src/lib.rs @@ -1,4 +1,4 @@ -//! Bytes conversions for [`dcb`]. +//! Bytes conversions for game types. // Features #![feature(unsafe_block_in_unsafe_fn, min_const_generics)] diff --git a/dcb/src/game/card/digimon/error.rs b/dcb/src/game/card/digimon/error.rs index ad66aaa..44723fb 100644 --- a/dcb/src/game/card/digimon/error.rs +++ b/dcb/src/game/card/digimon/error.rs @@ -3,7 +3,7 @@ // Imports use crate::{game::card::property, util::null_ascii_string}; -/// Error type for [`Bytes::from_bytes`] +/// Error type for [`Bytes::from_bytes`](dcb_bytes::Bytes::from_bytes) #[derive(PartialEq, Eq, Clone, Copy, Debug, thiserror::Error)] pub enum FromBytesError { /// Unable to read the digimon name @@ -75,7 +75,7 @@ pub enum FromBytesError { EffectThird(#[source] property::effect::FromBytesError), } -/// Error type for [`Bytes::to_bytes`] +/// Error type for [`Bytes::to_bytes`](dcb_bytes::Bytes::to_bytes) #[derive(PartialEq, Eq, Clone, Copy, Debug, thiserror::Error)] #[allow(clippy::pub_enum_variant_names)] // This is a general error, not a specific effect error pub enum ToBytesError { diff --git a/dcb/src/game/card/digivolve.rs b/dcb/src/game/card/digivolve.rs index 9fc57af..b8ab45e 100644 --- a/dcb/src/game/card/digivolve.rs +++ b/dcb/src/game/card/digivolve.rs @@ -35,7 +35,7 @@ pub struct Digivolve { pub unknown_15: [u8; 3], } -/// Error type for [`Bytes::from_bytes`] +/// Error type for [`Bytes::from_bytes`](dcb_bytes::Bytes::from_bytes) #[derive(PartialEq, Eq, Clone, Copy, Debug, thiserror::Error)] pub enum FromBytesError { /// Unable to read the digimon name diff --git a/dcb/src/game/card/item.rs b/dcb/src/game/card/item.rs index b20846f..3e7a114 100644 --- a/dcb/src/game/card/item.rs +++ b/dcb/src/game/card/item.rs @@ -53,7 +53,7 @@ pub struct Item { pub unknown_15: u32, } -/// Error type for [`Bytes::from_bytes`] +/// Error type for [`Bytes::from_bytes`](dcb_bytes::Bytes::from_bytes) #[derive(PartialEq, Eq, Clone, Copy, Debug, thiserror::Error)] pub enum FromBytesError { /// Unable to read the digimon name @@ -101,7 +101,7 @@ pub enum FromBytesError { EffectThird(#[source] property::effect::FromBytesError), } -/// Error type for [`Bytes::to_bytes`] +/// Error type for [`Bytes::to_bytes`](dcb_bytes::Bytes::to_bytes) #[derive(PartialEq, Eq, Clone, Copy, Debug, thiserror::Error)] #[allow(clippy::pub_enum_variant_names)] // This is a general error, not a specific effect error pub enum ToBytesError { diff --git a/dcb/src/game/card/property.rs b/dcb/src/game/card/property.rs index 21152cc..db7fc92 100644 --- a/dcb/src/game/card/property.rs +++ b/dcb/src/game/card/property.rs @@ -210,7 +210,7 @@ crate::generate_enum_property_mod!( } ); -/// An [`ArrowColor`] that may exist or not with a [`Bytes`] implementation +/// A possible [`ArrowColor`] #[repr(transparent)] #[derive(ref_cast::RefCast)] #[derive(derive_more::From, derive_more::Into)] @@ -218,7 +218,7 @@ crate::generate_enum_property_mod!( #[proxy_sentinel(value = 0, wrapper_type = "ArrowColor")] pub struct MaybeArrowColor(Option); -/// A [`CrossMoveEffect`] that may exist or not with a [`Bytes`] implementation +/// A possible [`CrossMoveEffect`] #[repr(transparent)] #[derive(ref_cast::RefCast)] #[derive(derive_more::From, derive_more::Into)] @@ -226,7 +226,7 @@ pub struct MaybeArrowColor(Option); #[proxy_sentinel(value = 0, wrapper_type = "CrossMoveEffect")] pub struct MaybeCrossMoveEffect(Option); -/// A [`DigimonProperty`] that may exist or not with a [`Bytes`] implementation +/// A possible [`DigimonProperty`] #[repr(transparent)] #[derive(ref_cast::RefCast)] #[derive(derive_more::From, derive_more::Into)] diff --git a/dcb/src/game/card/property/effect.rs b/dcb/src/game/card/property/effect.rs index 5441336..4bb72d7 100644 --- a/dcb/src/game/card/property/effect.rs +++ b/dcb/src/game/card/property/effect.rs @@ -159,7 +159,7 @@ pub enum Effect { }, } -/// Error type for [`Bytes::from_bytes`] +/// Error type for [`Bytes::from_bytes`](dcb_bytes::Bytes::from_bytes) #[derive(PartialEq, Eq, Clone, Copy, Debug, thiserror::Error)] pub enum FromBytesError { /// Unknown property for first property argument @@ -190,7 +190,7 @@ pub enum FromBytesError { }, } -/// Error type for [`Bytes::from_bytes`] +/// Error type for [`Bytes::from_bytes`](dcb_bytes::Bytes::from_bytes) #[derive(PartialEq, Eq, Clone, Copy, Debug, thiserror::Error)] pub enum ToBytesError { /// Invalid move [`Effect::MoveCards`] effect diff --git a/dcb/src/game/card/property/moves.rs b/dcb/src/game/card/property/moves.rs index 2ab75f5..8185973 100644 --- a/dcb/src/game/card/property/moves.rs +++ b/dcb/src/game/card/property/moves.rs @@ -34,7 +34,7 @@ pub struct Move { unknown: u32, } -/// Error type for [`Bytes::from_bytes`] +/// Error type for [`Bytes::from_bytes`](dcb_bytes::Bytes::from_bytes) #[derive(PartialEq, Eq, Clone, Copy, Debug, thiserror::Error)] pub enum FromBytesError { /// Unable to read the move name diff --git a/dcb/src/game/card/table.md b/dcb/src/game/card/table.md index 09ab022..c737afa 100644 --- a/dcb/src/game/card/table.md +++ b/dcb/src/game/card/table.md @@ -8,13 +8,13 @@ with a small header of `0xb` and then the table itself. The digimon table has a max size of [0x14950](Table::MAX_BYTE_SIZE), but does not necessary use all of this space, but it does follow this layout: -| Offset | Size | Type | Name | Details | -| ------ | -------- | --------------- | -------------------- | ----------------------------------------------------------------------- | -| 0x0 | 0x4 | u32 | Magic | Always contains the string "0ACD" (= [0x44434130](Table::HEADER_MAGIC)) | -| 0x4 | 0x2 | u16 | Number of digimon | | -| 0x6 | 0x1 | u8 | Number of items | | -| 0x7 | 0x1 | u8 | Number of digivolves | | -| 0x8 | variable | \[`CardEntry`\] | Card Entries | A contiguous array of [Card Entry](#card-entry-layout) | +| Offset | Size | Type | Name | Details | +| ------ | -------- | --------------------------------- | -------------------- | ----------------------------------------------------------------------- | +| 0x0 | 0x4 | u32 | Magic | Always contains the string "0ACD" (= [0x44434130](Table::HEADER_MAGIC)) | +| 0x4 | 0x2 | u16 | Number of digimon | | +| 0x6 | 0x1 | u8 | Number of items | | +| 0x7 | 0x1 | u8 | Number of digivolves | | +| 0x8 | variable | [`CardEntry`](#card-entry-layout) | Card Entries | A contiguous array of [Card Entry](#card-entry-layout) | # Card Entry Layout Each card entry consists of a header of the card diff --git a/dcb/src/game/deck.rs b/dcb/src/game/deck.rs index e6f4fd9..af92a76 100644 --- a/dcb/src/game/deck.rs +++ b/dcb/src/game/deck.rs @@ -56,7 +56,7 @@ generate_enum_property_mod! { } } -/// A [`City`] that may exist or not with a [`Bytes`] implementation +/// A possible [`City`] #[repr(transparent)] #[derive(ref_cast::RefCast)] #[derive(derive_more::From, derive_more::Into)] @@ -64,7 +64,7 @@ generate_enum_property_mod! { #[proxy_sentinel(value = 0, wrapper_type = "City")] pub struct MaybeCity(Option); -/// An [`ArmorEvo`] that may exist or not with a [`Bytes`] implementation +/// A possible [`ArmorEvo`] #[repr(transparent)] #[derive(ref_cast::RefCast)] #[derive(derive_more::From, derive_more::Into)] @@ -72,7 +72,7 @@ pub struct MaybeCity(Option); #[proxy_sentinel(value = 0, wrapper_type = "ArmorEvo")] pub struct MaybeArmorEvo(Option); -/// A [`Music`] that may exist or not with a [`Bytes`] implementation +/// A possible [`Music`] #[repr(transparent)] #[derive(ref_cast::RefCast)] #[derive(derive_more::From, derive_more::Into)] diff --git a/dcb/src/game/deck/deck.rs b/dcb/src/game/deck/deck.rs index 782b6e0..ea7d678 100644 --- a/dcb/src/game/deck/deck.rs +++ b/dcb/src/game/deck/deck.rs @@ -62,7 +62,7 @@ pub struct Deck { unknown_6a: u8, } -/// Error type for [`Bytes::from_bytes`] +/// Error type for [`Bytes::from_bytes`](dcb_bytes::Bytes::from_bytes) #[derive(PartialEq, Eq, Clone, Copy, Debug, thiserror::Error)] pub enum FromBytesError { /// Unable to read the deck name diff --git a/dcb/src/game/validation.rs b/dcb/src/game/validation.rs index a566efc..08a66e8 100644 --- a/dcb/src/game/validation.rs +++ b/dcb/src/game/validation.rs @@ -2,16 +2,17 @@ /// Structures that are validatable to be written to bytes. /// -/// This works in tandem with the [`Bytes`](crate::Bytes) interface to allow +/// This works in tandem with the [`Bytes`](dcb_bytes::Bytes) interface to allow /// applications which take user input to validate input before serializing it. /// -/// Although this information exists by calling [`Bytes::to_bytes`](crate::Bytes::to_bytes), +/// Although this information exists by calling [`Bytes::to_bytes`](dcb_bytes::Bytes::to_bytes), /// this interface provides two main advantages: /// /// 1. It is faster than serializing the data, as it doesn't need to write the raw bytes and /// can focus on simply parsing possible errors. /// 2. It provides warnings alongside the errors. These are also provided via `log::warn`, but /// these cannot be sent to the user easily. +// TODO: Move to `dcb-bytes`. pub trait Validatable { /// Error type for this validation type Error; diff --git a/dcb/src/util/impl_bytes.rs b/dcb/src/util/impl_bytes.rs index 4307642..90f4ae2 100644 --- a/dcb/src/util/impl_bytes.rs +++ b/dcb/src/util/impl_bytes.rs @@ -1,4 +1,4 @@ -//! Helper macros to implement [`Bytes`](crate::Bytes) +//! Helper macros to implement [`Bytes`](dcb_bytes::Bytes) /// Defines and implements a property enum // TODO: Make better documentation