pub trait DeserialCtxWithState<S>: Sized where
    S: HasStateApi
{ fn deserial_ctx_with_state<R: Read>(
        size_length: SizeLength,
        ensure_ordered: bool,
        state: &S,
        source: &mut R
    ) -> ParseResult<Self>; }
Expand description

The DeserialCtxWithState trait provides a means of reading structures from byte-sources (Read) using contextual information for types that also need a reference to a HasStateApi type. The trait is a combination of the DeserialCtx and DeserialWithState traits, which each has additional documentation.

This trait is primarily used when deriving DeserialWithState for struct or enums where both contextual information and the state is present.

For example:

#[derive(DeserialWithState)]
#[concordium(state_parameter = "S")]
struct MyStruct<S: HasStateApi> {
    #[concordium(size_length = 2)]
    a: String, // Gets the contextual size_length information.
    b: StateBox<u8, S>, // Needs a HasStateApi type
}

Required Methods

Attempt to read a structure from a given source, context, and state, failing if an error occurs during deserialization or reading.

Implementors

Blanket implementation of DeserialCtxWithState for any DeserialCtx types, which simply does not use the state argument.