pub trait Storage: Deref<Target = [u8]> + DerefMut<Target = [u8]> {
type Output;
// Required methods
fn try_push(&mut self, data: u8) -> Result<()>;
fn finalize(self) -> Self::Output;
// Provided method
fn try_extend(&mut self, data: &[u8]) -> Result<()> { ... }
}Expand description
Serialization storage, the output medium of the serialization
Serialization buffers can implement this trait to be used as an output with the serializer
e.g. whether the data is serialized to a u8 slice, or a Vec<u8, N>.
Required Associated Types§
Sourcetype Output
type Output
What this storage “resolves” to when the serialization is complete,
such as a u8 slice, or a Vec<u8, N>.
Required Methods§
Provided Methods§
Sourcefn try_extend(&mut self, data: &[u8]) -> Result<()>
fn try_extend(&mut self, data: &[u8]) -> Result<()>
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".