Struct ByteArrayReader

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

ByteArrayReader implements a Reader that can extract bytes from a borrowed slice of bytes.

Implementations§

Source§

impl<'a> ByteArrayReader<'a>

Source

pub fn new(buff: &'a [u8]) -> ByteArrayReader<'a>

Source

pub fn as_slice(&self) -> &[u8]

Returns a reference to the inner data as a slice.

Source

pub fn can_read(&self, count: usize) -> Result<()>

Verifies if the specified number of bytes can be read from this struct.

Returns:

  • Result(()): If it is possible to read the specified number of bytes;
  • Result(ErrorKind::UnableToReadData): If it is not possible to read the specified number of bytes;

Trait Implementations§

Source§

impl<'a> MemoryReader for ByteArrayReader<'a>

Source§

fn len(&self) -> usize

Returns the current size of the data.
Source§

fn offset(&self) -> usize

Returns the current offset of the data.
Source§

fn set_offset(&mut self, offset: usize)

Sets the current offset. If offset is larger than the length, it will set the offset to to the length of the data.
Source§

fn is_empty(&self) -> bool

Returns true if this reader is empty.
Source§

fn available(&self) -> usize

Returns the number of bytes available in the reader.
Source§

fn assert_can_read(&self, count: usize) -> Result<()>

This method verifies if a certain amount of bytes can be read/extracted. Read more
Source§

impl<'a> Reader for ByteArrayReader<'a>

Source§

fn read(&mut self) -> Result<u8>

Reads a single byte from the source. Read more
Source§

fn read_all(&mut self, buff: &mut [u8]) -> Result<()>

Reads the specified number of bytes from the source. Read more
Source§

fn skip(&mut self, count: usize) -> Result<()>

Skips some bytes from the source. Read more
Source§

fn skip_u64(&mut self, count: u64) -> Result<()>

Skips some bytes from the source using a u64 as its size. On 64-bit systems, this is equivalent to Self::skip() as usize is a 64-bit value. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ByteArrayReader<'a>

§

impl<'a> RefUnwindSafe for ByteArrayReader<'a>

§

impl<'a> Send for ByteArrayReader<'a>

§

impl<'a> Sync for ByteArrayReader<'a>

§

impl<'a> Unpin for ByteArrayReader<'a>

§

impl<'a> UnwindSafe for ByteArrayReader<'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<R> ByteArrayDeserializer for R
where R: Reader,

Source§

fn deserialize_bytes(&mut self, size: usize) -> Result<Vec<u8>, ErrorKind>

Deserializes a byte array of a given size. Read more
Source§

fn deserialize_bytes_into_slice( &mut self, buff: &mut [u8], ) -> Result<(), ErrorKind>

Deserializes a byte array of a given size into slice. Read more
Source§

fn deserialize_bytes_into_vec( &mut self, size: usize, vec: &mut Vec<u8>, ) -> Result<()>

Deserializes a byte array of a given size into a vector. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<R> ILIntDeserializer for R
where R: ILIntReader,

Source§

fn deserialize_ilint(&mut self) -> Result<u64, ErrorKind>

Deserializes an ILInt value. Read more
Source§

impl<T> ILIntReader for T
where T: Reader,

Source§

fn read_ilint(&mut self) -> Result<u64, ErrorKind>

Reads the ILInt. Read more
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<R> SignedILIntDeserializer for R

Source§

fn deserialize_signed_ilint(&mut self) -> Result<i64, ErrorKind>

Deserializes an ILInt value. Read more
Source§

impl<T> SignedILIntReader for T
where T: Reader,

Source§

fn read_signed_ilint(&mut self) -> Result<i64, ErrorKind>

Reads the ILInt. Read more
Source§

impl<R> StringDeserializer for R

Source§

fn deserialize_string(&mut self, size: usize) -> Result<String, ErrorKind>

Deserializes an UTF-8 String with a given size. Read more
Source§

impl<T> StringValueReader for T
where T: Reader,

Source§

fn read_string(&mut self, size: usize) -> Result<String, ErrorKind>

Reads an UTF-8 String with a given size. Read more
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.
Source§

impl<T, R> ValueDeserializer<T> for R
where T: Copy, R: ValueReader<T>,

Source§

fn deserialize_value(&mut self) -> Result<T, ErrorKind>

Deserializes the value. Read more
Source§

impl<T> ValueReader<f32> for T
where T: Reader,

Source§

fn read_value(&mut self) -> Result<f32, ErrorKind>

Reads the value. Read more
Source§

impl<T> ValueReader<f64> for T
where T: Reader,

Source§

fn read_value(&mut self) -> Result<f64, ErrorKind>

Reads the value. Read more
Source§

impl<T> ValueReader<i16> for T
where T: Reader,

Source§

fn read_value(&mut self) -> Result<i16, ErrorKind>

Reads the value. Read more
Source§

impl<T> ValueReader<i32> for T
where T: Reader,

Source§

fn read_value(&mut self) -> Result<i32, ErrorKind>

Reads the value. Read more
Source§

impl<T> ValueReader<i64> for T
where T: Reader,

Source§

fn read_value(&mut self) -> Result<i64, ErrorKind>

Reads the value. Read more
Source§

impl<T> ValueReader<i8> for T
where T: Reader,

Source§

fn read_value(&mut self) -> Result<i8, ErrorKind>

Reads the value. Read more
Source§

impl<T> ValueReader<u16> for T
where T: Reader,

Source§

fn read_value(&mut self) -> Result<u16, ErrorKind>

Reads the value. Read more
Source§

impl<T> ValueReader<u32> for T
where T: Reader,

Source§

fn read_value(&mut self) -> Result<u32, ErrorKind>

Reads the value. Read more
Source§

impl<T> ValueReader<u64> for T
where T: Reader,

Source§

fn read_value(&mut self) -> Result<u64, ErrorKind>

Reads the value. Read more
Source§

impl<T> ValueReader<u8> for T
where T: Reader,

Source§

fn read_value(&mut self) -> Result<u8, ErrorKind>

Reads the value. Read more