Trait postcard::flavors::SerFlavor [−][src]
pub trait SerFlavor { type Output; fn try_push(&mut self, data: u8) -> Result<(), ()>; fn release(self) -> Result<Self::Output, ()>; fn try_extend(&mut self, data: &[u8]) -> Result<(), ()> { ... } fn try_push_varint_usize(&mut self, data: &VarintUsize) -> Result<(), ()> { ... } }
Expand description
The SerFlavor trait acts as a combinator/middleware interface that can be used to pass bytes through storage or modification flavors. See the module level documentation for more information and examples.
Associated Types
type Output
[src]
Expand description
The Output
type is what this flavor “resolves” to when the serialization is complete.
For storage flavors, this is typically a concrete type. For modification flavors, this is
typically a generic parameter for the storage flavor they are wrapped around.
Required methods
fn try_push(&mut self, data: u8) -> Result<(), ()>
[src]
Expand description
The try_push() trait method can be used to push a single byte to be modified and/or stored
fn release(self) -> Result<Self::Output, ()>
[src]
Expand description
The release() trait method finalizes the modification or storage operation, and resolved into
the type defined by SerFlavor::Output
associated type.
Provided methods
fn try_extend(&mut self, data: &[u8]) -> Result<(), ()>
[src]
Expand description
The try_extend() trait method can be implemented when there is a more efficient way of processing multiple bytes at once, such as copying a slice to the output, rather than iterating over one byte at a time.
fn try_push_varint_usize(&mut self, data: &VarintUsize) -> Result<(), ()>
[src]
Expand description
The try_push_varint_usize() trait method can be used to push a VarintUsize
. The default
implementation uses try_extend() to process the encoded VarintUsize
bytes, which is likely
the desired behavior for most circumstances.