Skip to main content

SerializeWithLength

Struct SerializeWithLength 

Source
pub struct SerializeWithLength<'value, Length, Value> { /* private fields */ }
Expand description

Wrapper for serializing a value with a preceding length field.

See also Length::serialize.

§Examples

use rsomeip_bytes::{SerializeWithLength, LengthU32, Serialize as _};

let wrapper = SerializeWithLength::<LengthU32, _>::from(&1_u16);
assert_eq!(Some(6), wrapper.size());

let bytes = wrapper.to_bytes()?;
assert_eq!(&bytes, [0_u8, 0, 0, 2, 0, 1].as_slice());

Trait Implementations§

Source§

impl<'value, Length, Value> From<&'value Value> for SerializeWithLength<'value, Length, Value>
where Length: Length, Value: Serialize,

Source§

fn from(value: &'value Value) -> Self

Converts to this type from the input type.
Source§

impl<Length, Value> Serialize for SerializeWithLength<'_, Length, Value>
where Length: Length, Value: Serialize,

Source§

fn serialize<Buffer>( &self, buffer: &mut Buffer, ) -> Result<usize, SerializeError>
where Buffer: BufMut + ?Sized,

Serializes self into the given buffer. Read more
Source§

fn size(&self) -> Option<usize>

Returns the size of self when serialized. Read more
Source§

fn to_bytes(&self) -> Result<Bytes, SerializeError>

Returns self serialized into Bytes. Read more

Auto Trait Implementations§

§

impl<'value, Length, Value> Freeze for SerializeWithLength<'value, Length, Value>

§

impl<'value, Length, Value> RefUnwindSafe for SerializeWithLength<'value, Length, Value>
where Value: RefUnwindSafe, Length: RefUnwindSafe,

§

impl<'value, Length, Value> Send for SerializeWithLength<'value, Length, Value>
where Value: Sync, Length: Send,

§

impl<'value, Length, Value> Sync for SerializeWithLength<'value, Length, Value>
where Value: Sync, Length: Sync,

§

impl<'value, Length, Value> Unpin for SerializeWithLength<'value, Length, Value>
where Length: Unpin,

§

impl<'value, Length, Value> UnsafeUnpin for SerializeWithLength<'value, Length, Value>

§

impl<'value, Length, Value> UnwindSafe for SerializeWithLength<'value, Length, Value>
where Value: RefUnwindSafe, Length: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.