pub struct SerializeHandle<'a>(/* private fields */);Expand description
A handle to a value that is serialized.
During serialization it’s common to be in a situation where one needs
to return a locally constructed Serialize. This is where
SerializeHandle comes in. The handle either borrows the value (see
to and SerializeRef) or owns it (see
arena and heap).
Unlike the SinkHandle of deserialization,
which holds a sink that is already deserializing a value, this holds a
value that is not serialized yet. The serialization equivalent of a
sink is an emitter in a Emit. The constructors line up:
to borrows, arena and
heap own in the same way for both handles.
Implementations§
Source§impl<'a> SerializeHandle<'a>
impl<'a> SerializeHandle<'a>
Sourcepub fn to<S: Serialize>(value: &'a S) -> SerializeHandle<'a>
pub fn to<S: Serialize>(value: &'a S) -> SerializeHandle<'a>
Creates a borrowed handle to a value.
Sourcepub fn arena<S: Serialize + Send + 'a>(
value: S,
state: &mut State,
) -> SerializeHandle<'a>
pub fn arena<S: Serialize + Send + 'a>( value: S, state: &mut State, ) -> SerializeHandle<'a>
Creates an owned handle to a value in the arena of the state.
This is how owned values are typically created (for instance for
Emit::Forward), see Boxed.
Sourcepub fn heap<S: Serialize + Send + 'a>(value: S) -> SerializeHandle<'a>
pub fn heap<S: Serialize + Send + 'a>(value: S) -> SerializeHandle<'a>
Creates an owned handle to a value on the heap.
Unlike arena the value does not need a state and is
independent of any serialization.
Sourcepub fn get(&self) -> SerializeRef<'_>
pub fn get(&self) -> SerializeRef<'_>
Returns a reference to the value.