pub trait SerializationContext: Sized {
type ContextState: Default;
// Provided method
fn serialize_nested<O: PacketBuilder<Self>, R>(
&mut self,
_outer: &O,
constraints: PacketConstraints,
serialize_fn: impl FnOnce(&mut Self, PacketConstraints) -> R,
) -> R { ... }
}Expand description
Context in which packet serialization is performed.
Required Associated Types§
Sourcetype ContextState: Default
type ContextState: Default
The packet-specific state required by this serialization context.
Provided Methods§
Sourcefn serialize_nested<O: PacketBuilder<Self>, R>(
&mut self,
_outer: &O,
constraints: PacketConstraints,
serialize_fn: impl FnOnce(&mut Self, PacketConstraints) -> R,
) -> R
fn serialize_nested<O: PacketBuilder<Self>, R>( &mut self, _outer: &O, constraints: PacketConstraints, serialize_fn: impl FnOnce(&mut Self, PacketConstraints) -> R, ) -> R
Performs nested serialization within the context of an outer
PacketBuilder.
The provided serialize_fn is expected to serialize the packet body and
then the packet header and/or footer, each with the provided context.
The implementor is expected to call serialize_fn and return the result
without modification, but it may update its internal state before and/or
after doing so if necessary.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.