Skip to main content

CdrReader

Struct CdrReader 

Source
pub struct CdrReader<'a> { /* private fields */ }
Expand description

Reads primitives from a little-endian CDR buffer, handling alignment padding.

The reader checks the encapsulation header on construction and then mirrors CdrWriter’s alignment, so a value written by the writer is read back identically.

Implementations§

Source§

impl<'a> CdrReader<'a>

Source

pub fn new(data: &'a [u8]) -> Option<Self>

Creates a reader over a CDR buffer.

§Arguments
  • data - the CDR-encoded buffer, including the four-byte encapsulation header.
§Returns

Some(reader) if data carries a classic little-endian CDR header; None otherwise, including a buffer too short to hold a header or one declaring a byte order this reader does not decode.

Source

pub fn read_i32(&mut self) -> Option<i32>

Reads a 32-bit signed integer.

§Returns

Some(value), or None if the buffer is exhausted.

Source

pub fn read_u32(&mut self) -> Option<u32>

Reads a 32-bit unsigned integer.

§Returns

Some(value), or None if the buffer is exhausted.

Source

pub fn read_f32(&mut self) -> Option<f32>

Reads a 32-bit float.

§Returns

Some(value), or None if the buffer is exhausted.

Source

pub fn read_f64(&mut self) -> Option<f64>

Reads a 64-bit float.

§Returns

Some(value), or None if the buffer is exhausted.

Auto Trait Implementations§

§

impl<'a> Freeze for CdrReader<'a>

§

impl<'a> RefUnwindSafe for CdrReader<'a>

§

impl<'a> Send for CdrReader<'a>

§

impl<'a> Sync for CdrReader<'a>

§

impl<'a> Unpin for CdrReader<'a>

§

impl<'a> UnsafeUnpin for CdrReader<'a>

§

impl<'a> UnwindSafe for CdrReader<'a>

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.