pub struct BufferReader<'a> { /* private fields */ }Expand description
Read buffer with alignment tracking.
Implementations§
Source§impl<'a> BufferReader<'a>
impl<'a> BufferReader<'a>
Sourcepub fn new(bytes: &'a [u8], endianness: Endianness) -> Self
pub fn new(bytes: &'a [u8], endianness: Endianness) -> Self
Constructs a reader over the given slice (XCDR1 cap 8).
Sourcepub fn with_align_origin(self, origin: usize) -> Self
pub fn with_align_origin(self, origin: usize) -> Self
Builder: sets the virtual Self::align origin (default 0).
For GIOP 1.2 = 12 (header size), MUST match the encode side.
Sourcepub fn with_max_alignment(self, max_alignment: usize) -> Self
pub fn with_max_alignment(self, max_alignment: usize) -> Self
Builder: sets the alignment cap (XCDR1=8, XCDR2=4). Inherited by nested member readers.
Sourcepub fn max_alignment(&self) -> usize
pub fn max_alignment(&self) -> usize
The current alignment cap (8 = XCDR1, 4 = XCDR2).
Sourcepub fn endianness(&self) -> Endianness
pub fn endianness(&self) -> Endianness
Current endianness.
Sourcepub fn align(&mut self, alignment: usize) -> Result<(), DecodeError>
pub fn align(&mut self, alignment: usize) -> Result<(), DecodeError>
Skips padding until the next alignment boundary.
§Errors
UnexpectedEof when not enough bytes remain for the padding.
Sourcepub fn read_bytes(&mut self, n: usize) -> Result<&'a [u8], DecodeError>
pub fn read_bytes(&mut self, n: usize) -> Result<&'a [u8], DecodeError>
Sourcepub fn read_u8(&mut self) -> Result<u8, DecodeError>
pub fn read_u8(&mut self) -> Result<u8, DecodeError>
Sourcepub fn read_u16(&mut self) -> Result<u16, DecodeError>
pub fn read_u16(&mut self) -> Result<u16, DecodeError>
Sourcepub fn read_u32(&mut self) -> Result<u32, DecodeError>
pub fn read_u32(&mut self) -> Result<u32, DecodeError>
Sourcepub fn read_u64(&mut self) -> Result<u64, DecodeError>
pub fn read_u64(&mut self) -> Result<u64, DecodeError>
Sourcepub fn read_string(&mut self) -> Result<String, DecodeError>
pub fn read_string(&mut self) -> Result<String, DecodeError>
Reads a CDR string (§9.3.2.7): 4-byte length (incl. null terminator) + UTF-8 bytes + 1 null byte. Returns the string without the terminator.
§Errors
UnexpectedEof for too-short data; InvalidData for non-UTF-8
bytes, a missing null terminator, or length == 0.
Trait Implementations§
Source§impl<'a> Clone for BufferReader<'a>
impl<'a> Clone for BufferReader<'a>
Source§fn clone(&self) -> BufferReader<'a>
fn clone(&self) -> BufferReader<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<'a> Freeze for BufferReader<'a>
impl<'a> RefUnwindSafe for BufferReader<'a>
impl<'a> Send for BufferReader<'a>
impl<'a> Sync for BufferReader<'a>
impl<'a> Unpin for BufferReader<'a>
impl<'a> UnsafeUnpin for BufferReader<'a>
impl<'a> UnwindSafe for BufferReader<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more