Struct rubble::bytes::ByteReader[][src]

pub struct ByteReader<'a>(&'a [u8]);
Expand description

Allows reading values from a borrowed byte slice.

Tuple Fields

0: &'a [u8]

Implementations

Creates a new ByteReader that will read from the given byte slice.

Returns a reference to the raw bytes in self, without advancing self or reading any data.

Consumes self and returns the part of the contained buffer that has not yet been read from.

Skips the given number of bytes in the input data without inspecting them.

This is a potentially dangerous operation that should only be used when the bytes really do not matter.

Creates and returns another ByteReader that will read from the next len Bytes in the buffer.

self will be modified to point after the split-off bytes, and will continue reading from there.

Note that if the created ByteReader is not used, the bytes will be ignored. If you are really sure you want that, skip is a more explicit way of accomplishing that.

Returns the number of bytes that can still be read from self.

Returns whether self is at the end of the underlying buffer (EOF).

If this returns true, no data can be read from self anymore.

Reads a zerocopy-supported object from the stream by transmuting an appropriate number of bytes.

Reads a byte slice of length len from self.

If self contains less than len bytes, Error::Eof will be returned and self will not be modified.

Reads a byte-array-like type S from self.

S must implement Default and AsMut<[u8]>, which allows using small arrays up to 32 bytes as well as datastructures from alloc (eg. Box<[u8]> or Vec<u8>).

Reads the remaining bytes from self.

Reads a single byte from self.

Returns Error::Eof when self is empty.

Reads a u16 from self, using Little Endian byte order.

Reads a u32 from self, using Little Endian byte order.

Reads a u64 from self, using Little Endian byte order.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.