pub struct SymbolMap { /* private fields */ }
Expand description
A list of previously serialized symbols.
Implementations§
source§impl SymbolMap
impl SymbolMap
sourcepub const fn with_compatibility(self, compatibility: Compatibility) -> Self
pub const fn with_compatibility(self, compatibility: Compatibility) -> Self
Sets the compatibility mode for serializing and returns self.
sourcepub fn set_compatibility(&mut self, compatibility: Compatibility)
pub fn set_compatibility(&mut self, compatibility: Compatibility)
Sets the compatibility mode for serializing.
sourcepub fn serializer_for<W: WriteBytesExt>(
&mut self,
output: W,
) -> Result<Serializer<'_, W>>
pub fn serializer_for<W: WriteBytesExt>( &mut self, output: W, ) -> Result<Serializer<'_, W>>
Returns a serializer that writes into output
and persists symbols
into self
.
sourcepub fn serialize_to<T, W>(&mut self, writer: W, value: &T) -> Result<()>
pub fn serialize_to<T, W>(&mut self, writer: W, value: &T) -> Result<()>
Serializes value
into writer
while persisting symbols into self
.
sourcepub fn serialize_to_vec<T>(&mut self, value: &T) -> Result<Vec<u8>>where
T: Serialize,
pub fn serialize_to_vec<T>(&mut self, value: &T) -> Result<Vec<u8>>where
T: Serialize,
Serializes value
into a new Vec<u8>
while persisting symbols into
self
.
sourcepub fn insert(&mut self, symbol: &str) -> bool
pub fn insert(&mut self, symbol: &str) -> bool
Inserts symbol
into this map.
Returns true if this symbol had not previously been registered. Returns false if the symbol was already included in the map.
sourcepub fn populate_from<T>(
&mut self,
value: &T,
) -> Result<usize, SymbolMapPopulationError>where
T: Serialize,
pub fn populate_from<T>(
&mut self,
value: &T,
) -> Result<usize, SymbolMapPopulationError>where
T: Serialize,
Adds all symbols encountered in value
.
Returns the number of symbols added.
Due to how serde works, this function can only encounter symbols that
are being used. For example, if T
is an enum, only variant being
passed in will have its name, and additional calls for each variant will
be needed to ensure every symbol is added.