Struct ttf_parser::parser::Stream[][src]

pub struct Stream<'a> { /* fields omitted */ }
Expand description

A streaming binary parser.

Implementations

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

pub fn new(data: &'a [u8]) -> Self[src]

Creates a new Stream parser.

pub fn new_at(data: &'a [u8], offset: usize) -> Option<Self>[src]

Creates a new Stream parser at offset.

Returns None when offset is out of bounds.

pub fn at_end(&self) -> bool[src]

Checks that stream reached the end of the data.

pub fn jump_to_end(&mut self)[src]

Jumps to the end of the stream.

Useful to indicate that we parsed all the data.

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

Returns the current offset.

pub fn tail(&self) -> Option<&'a [u8]>[src]

Returns the trailing data.

Returns None when Stream is reached the end.

pub fn skip<T: FromData>(&mut self)[src]

Advances by FromData::SIZE.

Doesn’t check bounds.

pub fn advance(&mut self, len: usize)[src]

Advances by the specified len.

Doesn’t check bounds.

pub fn advance_checked(&mut self, len: usize) -> Option<()>[src]

Advances by the specified len and checks for bounds.

pub fn read<T: FromData>(&mut self) -> Option<T>[src]

Parses the type from the steam.

Returns None when there is not enough data left in the stream or the type parsing failed.

pub fn read_at<T: FromData>(data: &[u8], offset: usize) -> Option<T>[src]

Parses the type from the steam at offset.

pub fn read_bytes(&mut self, len: usize) -> Option<&'a [u8]>[src]

Reads N bytes from the stream.

pub fn read_array16<T: FromData>(
    &mut self,
    count: u16
) -> Option<LazyArray16<'a, T>>
[src]

Reads the next count types as a slice.

pub fn read_array32<T: FromData>(
    &mut self,
    count: u32
) -> Option<LazyArray32<'a, T>>
[src]

Reads the next count types as a slice.

Trait Implementations

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

fn clone(&self) -> Stream<'a>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

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

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<'a> Default for Stream<'a>[src]

fn default() -> Stream<'a>[src]

Returns the “default value” for a type. Read more

impl<'a> Copy for Stream<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Stream<'a>

impl<'a> Send for Stream<'a>

impl<'a> Sync for Stream<'a>

impl<'a> Unpin for Stream<'a>

impl<'a> UnwindSafe for Stream<'a>

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.