[][src]Struct frombytes::Bytes

pub struct Bytes<'a> { /* fields omitted */ }

A cursor over a slice of bytes.

Implementations

impl<'a> Bytes<'a>[src]

pub const fn from_slice(bytes: &'a [u8]) -> Self[src]

Returns a new cursor over a slice of bytes.

pub const fn into_inner(self) -> &'a [u8][src]

Consumes the Bytes and returns the underlying data.

pub const fn position(&self) -> usize[src]

Returns the current position of the Bytes.

pub fn advance(&mut self, size: usize) -> Result<()>[src]

Advances the position in the bytes.

pub fn align(&mut self, align: usize) -> Result<()>[src]

Aligns the bytes to a particular word.

Panics

If the align size is a not one of the following powers of two: 1, 2, 4, 8, or 16.

pub fn read<T: FromBytes>(&mut self) -> Result<T, <T as FromBytes>::Error>[src]

Allows types implementing FromBytes to be easily read from these bytes.

Examples

let mut bytes = Bytes::from_slice(&[0x78, 0x56, 0x34, 0x12]);
let value: u32 = bytes.read().unwrap();
assert_eq!(value, 0x12345678);

Trait Implementations

impl<'a> Clone for Bytes<'a>[src]

impl<'a> Debug for Bytes<'a>[src]

impl<'a> From<&'a [u8]> for Bytes<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Bytes<'a>

impl<'a> Send for Bytes<'a>

impl<'a> Sync for Bytes<'a>

impl<'a> Unpin for Bytes<'a>

impl<'a> UnwindSafe for Bytes<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.