SubRecord

Trait SubRecord 

Source
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§

Provided Associated Constants§

Required Methods§

Source

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.

Source

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.

Source

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§

Source

fn _serialize_chained<W: Write>(&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.

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.

Implementations on Foreign Types§

Source§

impl<'de> SubRecord<'de> for bool

Source§

impl<'raw> SubRecord<'raw> for &'raw str

Source§

impl<'raw> SubRecord<'raw> for f32

Source§

impl<'raw> SubRecord<'raw> for f64

Source§

impl<'raw> SubRecord<'raw> for i16

Source§

impl<'raw> SubRecord<'raw> for i32

Source§

impl<'raw> SubRecord<'raw> for i64

Source§

impl<'raw> SubRecord<'raw> for u8

Source§

impl<'raw> SubRecord<'raw> for u16

Source§

impl<'raw> SubRecord<'raw> for u32

Source§

impl<'raw> SubRecord<'raw> for u64

Source§

impl<'raw> SubRecord<'raw> for String

Source§

impl<'raw, K, V> SubRecord<'raw> for HashMap<K, V>
where K: SubRecordHashMapKey<'raw>, V: SubRecord<'raw>,

Source§

impl<'raw, T> SubRecord<'raw> for Vec<T>
where T: SubRecord<'raw>,

Implementors§