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

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

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]

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

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

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

Auto Trait Implementations

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

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

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

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

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

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.