pub trait DeserialCtxWithState<S>: Sizedwhere
S: HasStateApi,{
// Required method
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§
Sourcefn deserial_ctx_with_state<R: Read>(
size_length: SizeLength,
ensure_ordered: bool,
state: &S,
source: &mut R,
) -> ParseResult<Self>
fn deserial_ctx_with_state<R: Read>( size_length: SizeLength, ensure_ordered: bool, state: &S, source: &mut R, ) -> ParseResult<Self>
Attempt to read a structure from a given source, context, and state, failing if an error occurs during deserialization or reading.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<D: DeserialCtx, S: HasStateApi> DeserialCtxWithState<S> for D
Blanket implementation of DeserialCtxWithState for any DeserialCtx types, which simply does not use the state argument.