Trait bebop::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.

Implementations on Foreign Types§

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

Implementors§