Skip to main content

CdrDecoder

Struct CdrDecoder 

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

CDR Decoder with fixed buffer

§Example

let mut decoder = CdrDecoder::new(&buf);

let value: u32 = decoder.decode_u32()?;
let text = decoder.decode_string_borrowed()?;

Implementations§

Source§

impl<'a> CdrDecoder<'a>

Source

pub const fn new(buf: &'a [u8]) -> Self

Create a new CDR decoder

Source

pub const fn position(&self) -> usize

Get current position

Source

pub const fn remaining(&self) -> usize

Get remaining bytes

Source

pub fn decode_u8(&mut self) -> Result<u8>

Decode u8

Source

pub fn decode_i8(&mut self) -> Result<i8>

Decode i8

Source

pub fn decode_bool(&mut self) -> Result<bool>

Decode bool

Source

pub fn decode_u16(&mut self) -> Result<u16>

Decode u16

Source

pub fn decode_i16(&mut self) -> Result<i16>

Decode i16

Source

pub fn decode_u32(&mut self) -> Result<u32>

Decode u32

Source

pub fn decode_i32(&mut self) -> Result<i32>

Decode i32

Source

pub fn decode_u64(&mut self) -> Result<u64>

Decode u64

Source

pub fn decode_i64(&mut self) -> Result<i64>

Decode i64

Source

pub fn decode_f32(&mut self) -> Result<f32>

Decode f32

Source

pub fn decode_f64(&mut self) -> Result<f64>

Decode f64

Source

pub fn decode_string_borrowed(&mut self) -> Result<&'a str>

Decode string (borrowed, zero-copy)

Returns &str pointing to buffer (without null terminator)

Source

pub fn decode_bytes(&mut self, count: usize) -> Result<&'a [u8]>

Decode byte array (borrowed)

Source

pub fn decode_seq_len(&mut self) -> Result<usize>

Decode sequence length prefix (u32)

Used for decoding bounded sequences/arrays with variable length.

Auto Trait Implementations§

§

impl<'a> Freeze for CdrDecoder<'a>

§

impl<'a> RefUnwindSafe for CdrDecoder<'a>

§

impl<'a> Send for CdrDecoder<'a>

§

impl<'a> Sync for CdrDecoder<'a>

§

impl<'a> Unpin for CdrDecoder<'a>

§

impl<'a> UnsafeUnpin for CdrDecoder<'a>

§

impl<'a> UnwindSafe for CdrDecoder<'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.