pub trait Serialize: DataType {
// Required methods
fn size_bits(&self) -> usize;
fn serialize(&self, cursor: &mut WriteCursor<'_>);
// Provided method
fn serialize_to_bytes(&self, bytes: &mut [u8]) { ... }
}Expand description
Trait for types that can be serialized into Cyphal transfers
Required Methods§
Sourcefn size_bits(&self) -> usize
fn size_bits(&self) -> usize
Returns the size of the encoded form of this value, in bits
The returned value may not be a multiple of 8.
Sourcefn serialize(&self, cursor: &mut WriteCursor<'_>)
fn serialize(&self, cursor: &mut WriteCursor<'_>)
Serializes this value into a buffer
The provided cursor will allow writing at least the number of bits returned by the
size_bits() function.
Provided Methods§
Sourcefn serialize_to_bytes(&self, bytes: &mut [u8])
fn serialize_to_bytes(&self, bytes: &mut [u8])
A convenience function that creates a cursor around the provided bytes and calls
serialize
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.