pub trait TryPackAs<Marker: ?Sized> {
// Required methods
fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>;
fn pack_as_len(&self) -> Result<usize>;
}Expand description
Trait implemented by data types that support being serialized to a specific spinel-based byte encoding, based on the marker type.
The generic parameter Marker is effectiely a part of the name of the
trait and is not used directly by the trait. Types may implement more than
one instance of this trait, each with a different marker type.
For example, structs that use the spinel_packed attribute macro
will implement both TryPackAs<[u8]> and TryPackAs<SpinelDataWlen>
for handling the D and d Spinel field formats respectively when
serializing.
Required Methods§
Sourcefn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>
fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>
Uses Spinel encoding to serialize to a given std::io::Write reference as the
Spinel type identified by Marker.
Sourcefn pack_as_len(&self) -> Result<usize>
fn pack_as_len(&self) -> Result<usize>
Calculates how many bytes this type will use when serialized.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".