diff --git a/Cargo.lock b/Cargo.lock index 2dc47ee76..03cc20d9a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1589,7 +1589,7 @@ dependencies = [ [[package]] name = "tls_codec" -version = "0.4.0-pre.3" +version = "0.4.0-pre.4" dependencies = [ "anstyle", "anstyle-parse", @@ -1605,7 +1605,7 @@ dependencies = [ [[package]] name = "tls_codec_derive" -version = "0.4.0-pre.3" +version = "0.4.0-pre.4" dependencies = [ "proc-macro2", "quote", diff --git a/tls_codec/Cargo.toml b/tls_codec/Cargo.toml index 65631c133..bb293486d 100644 --- a/tls_codec/Cargo.toml +++ b/tls_codec/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tls_codec" -version = "0.4.0-pre.3" +version = "0.4.0-pre.4" authors = ["RustCrypto Developers"] license = "Apache-2.0 OR MIT" documentation = "https://docs.rs/tls_codec/" @@ -18,7 +18,7 @@ zeroize = { version = "1.7", default-features = false, features = [ # optional dependencies arbitrary = { version = "1.3", features = ["derive"], optional = true } -tls_codec_derive = { version = "=0.4.0-pre.3", path = "./derive", optional = true } +tls_codec_derive = { version = "=0.4.0-pre.4", path = "./derive", optional = true } serde = { version = "1.0.184", features = ["derive"], optional = true } [dev-dependencies] diff --git a/tls_codec/derive/Cargo.toml b/tls_codec/derive/Cargo.toml index ce57c584d..97fb8fc62 100644 --- a/tls_codec/derive/Cargo.toml +++ b/tls_codec/derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tls_codec_derive" -version = "0.4.0-pre.3" +version = "0.4.0-pre.4" authors = ["RustCrypto Developers"] license = "Apache-2.0 OR MIT" documentation = "https://docs.rs/tls_codec_derive/" diff --git a/tls_codec/derive/src/lib.rs b/tls_codec/derive/src/lib.rs index 1c4d7e339..d9653366b 100644 --- a/tls_codec/derive/src/lib.rs +++ b/tls_codec/derive/src/lib.rs @@ -1223,19 +1223,28 @@ fn partition_skipped( ) } -/// The `conditionally_deserializable` attribute macro takes as input either -/// `Bytes` or `Reader` and does the following: -/// * Add a boolean const generic to the struct indicating if the variant of the -/// struct is deserializable or not. -/// * Depending on the input derive either the `TlsDeserialize` or -/// `TlsDeserializeBytes` trait for the deserializable variant -/// * Create type aliases for the deserializable and undeserializable variant of -/// the struct, where the alias is the name of the struct prefixed with -/// `Deserializable` or `Undeserializable` respectively. +/// The `conditionally_deserializable` attribute macro creates two versions of +/// the affected struct: One that implements the +/// [`Deserialize`](../tls_codec::Deserialize) and +/// [`DeserializeBytes`](../tls_codec::DeserializeBytes) traits and one that +/// does not. It does so by introducing a boolean const generic that indicates +/// if the struct can be deserialized or not. +/// +/// This conditional deserialization can be used, for example, to implement a +/// simple state machine, where after deserialization, the user must first +/// complete an additional transition (e.g. verification) to the +/// undeserializable version of the struct, which might then implement functions +/// for further processing. +/// +/// For ease of use, the macro creates type aliases for the deserializable and +/// undeserializable variant of the struct, where the alias is the name of the +/// struct prefixed with `Deserializable` or `Undeserializable` respectively. +/// +/// Due to the way that the macro rewrites the struct, it must be placed before +/// any `#[derive(...)]` statements. /// /// The `conditionally_deserializable` attribute macro is only available if the /// `conditional_deserialization` feature is enabled. -/// #[cfg_attr( feature = "conditional_deserialization", doc = r##"