Trait elrond_codec::NestedEncode
source · [−]pub trait NestedEncode: Sized {
fn dep_encode<O: NestedEncodeOutput>(
&self,
dest: &mut O
) -> Result<(), EncodeError>;
fn dep_encode_or_exit<O: NestedEncodeOutput, ExitCtx: Clone>(
&self,
dest: &mut O,
c: ExitCtx,
exit: fn(_: ExitCtx, _: EncodeError) -> !
) { ... }
}Expand description
Trait that allows zero-copy write of value-references to slices in LE format.
Implementations should override using_top_encoded for value types and dep_encode and size_hint for allocating types.
Wrapper types should override all methods.
Required methods
fn dep_encode<O: NestedEncodeOutput>(
&self,
dest: &mut O
) -> Result<(), EncodeError>
fn dep_encode<O: NestedEncodeOutput>(
&self,
dest: &mut O
) -> Result<(), EncodeError>
NestedEncode to output, using the format of an object nested inside another structure. Does not provide compact version.
Provided methods
fn dep_encode_or_exit<O: NestedEncodeOutput, ExitCtx: Clone>(
&self,
dest: &mut O,
c: ExitCtx,
exit: fn(_: ExitCtx, _: EncodeError) -> !
)
fn dep_encode_or_exit<O: NestedEncodeOutput, ExitCtx: Clone>(
&self,
dest: &mut O,
c: ExitCtx,
exit: fn(_: ExitCtx, _: EncodeError) -> !
)
Version of top_decode that exits quickly in case of error.
Its purpose is to create smaller implementations
in cases where the application is supposed to exit directly on decode error.