ChiselLittleEndian

Struct ChiselLittleEndian 

Source
pub struct ChiselLittleEndian<'a, S: ChiselSource>(/* private fields */);
Expand description

A Chisel, with little-endian byte order.

See the crate documentation for more information.

Implementations§

Source§

impl<'a, S: ChiselSource> ChiselLittleEndian<'a, S>

Source

pub fn inner(&mut self) -> &mut Chisel<S>

Returns a reference to the inner Chisel.

Source

pub fn into_inner(self) -> &'a mut Chisel<S>

Consumes the wrapper, returning the input chisel reference.

Source

pub fn error<E>(&self, err: E, backstep: usize) -> ChiselError<E, S::Error>

Returns a format error that occurred backstep bytes ago.

This is a convenience method for manually determining the appropriate byte offset and calling ChiselError::format.

Source

pub fn offset(&self) -> usize

Returns the current byte offset of the Chisel.

Source

pub fn read_buf(&mut self, buf: &mut [u8]) -> InfallibleFormatResult<(), S>

Fills a provided buffer with bytes from the source.

This operation is endian-independent.

§Errors

This function returns an ChiselErrorData::EndOfInput if the end of the input is encountered before the buffer is completely filled.

If an error is returned, the contents of buf are unspecified and the chisel breaks.

Source

pub fn u8(&mut self) -> InfallibleFormatResult<u8, S>

Reads a single byte u8.

This operation is endian-independent.

Source

pub fn u16(&mut self) -> InfallibleFormatResult<u16, S>

Reads a single u16 in little-endian byte order.

§Errors

If an error is returned, the chisel breaks.

Source

pub fn u32(&mut self) -> InfallibleFormatResult<u32, S>

Reads a single u32 in little-endian byte order.

§Errors

If an error is returned, the chisel breaks.

Source

pub fn u64(&mut self) -> InfallibleFormatResult<u64, S>

Reads a single u64 in little-endian byte order.

§Errors

If an error is returned, the chisel breaks.

Source

pub fn i8(&mut self) -> InfallibleFormatResult<i8, S>

Reads a single signed byte i8.

This operation is endian-independent.

Source

pub fn i16(&mut self) -> InfallibleFormatResult<i16, S>

Reads a single i16 in little-endian byte order.

§Errors

If an error is returned, the chisel breaks.

Source

pub fn i32(&mut self) -> InfallibleFormatResult<i32, S>

Reads a single i32 in little-endian byte order.

§Errors

If an error is returned, the chisel breaks.

Source

pub fn i64(&mut self) -> InfallibleFormatResult<i64, S>

Reads a single i64 in little-endian byte order.

§Errors

If an error is returned, the chisel breaks.

Source

pub fn f32(&mut self) -> InfallibleFormatResult<f32, S>

Reads a single f32 in little-endian byte order.

§Errors

If an error is returned, the chisel breaks.

Source

pub fn f64(&mut self) -> InfallibleFormatResult<f64, S>

Reads a single f64 in little-endian byte order.

§Errors

If an error is returned, the chisel breaks.

Source

pub fn skip(&mut self, how_many: usize) -> InfallibleFormatResult<(), S>

Skips how_many bytes of the underlying source.

This operation is endian-independent.

This is provided for optimization reasons. This hint is forwarded to the source.

Exactly how_many bytes are skipped, as-if read_buf were called with a buffer of appropriate size, with the buffer being discarded.

§Errors

If an end-of-input condition occurs before how_many bytes are skipped, an ChiselErrorData::EndOfInput error is returned.

If an error is returned, the chisel breaks.

Source

pub fn read_until( &mut self, byte: u8, dest: &mut Vec<u8>, ) -> InfallibleFormatResult<(), S>

Reads bytes into the provided dest Vec until the delimiter byte is encountered.

This operation is endian-independent.

§Errors

If the end of the input is encountered before the delimiter is found, ChiselErrorData::EndOfInput is returned.

If an error is returned, the chisel breaks.

Source

pub fn read_until_or_end( &mut self, byte: u8, dest: &mut Vec<u8>, ) -> InfallibleFormatResult<ReadUntilStopReason, S>

Reads bytes into the provided dest Vec until the delimiter byte or end-of-input is encountered.

This operation is endian-independent.

§Errors

If an error is returned, the chisel breaks.

Auto Trait Implementations§

§

impl<'a, S> Freeze for ChiselLittleEndian<'a, S>

§

impl<'a, S> RefUnwindSafe for ChiselLittleEndian<'a, S>
where S: RefUnwindSafe,

§

impl<'a, S> Send for ChiselLittleEndian<'a, S>
where S: Send,

§

impl<'a, S> Sync for ChiselLittleEndian<'a, S>
where S: Sync,

§

impl<'a, S> Unpin for ChiselLittleEndian<'a, S>

§

impl<'a, S> !UnwindSafe for ChiselLittleEndian<'a, S>

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.