Struct ogg::reading::PageParser

source ·
pub struct PageParser { /* private fields */ }
Expand description

Helper struct for parsing pages

It’s created using the new function and then it’s fed more data via the parse_segments and parse_packet_data functions, each called exactly once and in that precise order.

Then later code uses the OggPage returned by the parse_packet_data function.

Implementations§

source§

impl PageParser

source

pub fn new(header_buf: [u8; 27]) -> Result<(PageParser, usize), OggReadError>

Creates a new Page parser

The header_buf param contains the first 27 bytes of a new OGG page. Determining when one begins is your responsibility. Usually they begin directly after the end of a previous OGG page, but after you’ve performed a seek you might end up within the middle of a page and need to recapture.

Returns a page parser, and the requested size of the segments array. You should allocate and fill such an array, in order to pass it to the parse_segments function.

source

pub fn parse_segments(&mut self, segments_buf: Vec<u8>) -> usize

Parses the segments buffer, and returns the requested size of the packets content array.

You should allocate and fill such an array, in order to pass it to the parse_packet_data function.

source

pub fn parse_packet_data( self, packet_data: Vec<u8> ) -> Result<OggPage, OggReadError>

Parses the packets data and verifies the checksum.

Returns an OggPage to be used by later code.

Auto Trait Implementations§

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<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.