pub trait SubRecord<'raw>: Sized {
const MIN_SERIALIZED_SIZE: usize;
const EXACT_SERIALIZED_SIZE: Option<usize> = None;
// Required methods
fn serialized_size(&self) -> usize;
unsafe fn _serialize_chained_unaligned<W: Write>(
zelf: *const Self,
dest: &mut W,
) -> SeResult<usize>;
fn _deserialize_chained(raw: &'raw [u8]) -> DeResult<(usize, Self)>;
// Provided method
fn _serialize_chained<W: Write>(&self, dest: &mut W) -> SeResult<usize> { ... }
}Expand description
Internal trait used to reduce the amount of code that needs to be generated.
Required Associated Constants§
const MIN_SERIALIZED_SIZE: usize
Provided Associated Constants§
const EXACT_SERIALIZED_SIZE: Option<usize> = None
Required Methods§
Sourcefn serialized_size(&self) -> usize
fn serialized_size(&self) -> usize
Exact size this will be once serialized in bytes.
Warning: call is recursive and costly to make if not needed.
Sourceunsafe fn _serialize_chained_unaligned<W: Write>(
zelf: *const Self,
dest: &mut W,
) -> SeResult<usize>
unsafe fn _serialize_chained_unaligned<W: Write>( zelf: *const Self, dest: &mut W, ) -> SeResult<usize>
Should only be called from generated code! Serialize this record. It is highly recommend to use a buffered writer.
This allows the value to be unaligned.
§Safety
This function assumes that zelf is a valid, readable, initialized pointer to a Self
object. zelf does not need to be aligned.
Sourcefn _deserialize_chained(raw: &'raw [u8]) -> DeResult<(usize, Self)>
fn _deserialize_chained(raw: &'raw [u8]) -> DeResult<(usize, Self)>
Should only be called from generated code! Deserialize this object as a sub component of a larger message. Returns a tuple of (bytes_read, deserialized_value).
Provided Methods§
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.