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
impl PageParser
sourcepub fn new(header_buf: [u8; 27]) -> Result<(PageParser, usize), OggReadError>
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.
sourcepub fn parse_segments(&mut self, segments_buf: Vec<u8>) -> usize
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.
sourcepub fn parse_packet_data(
self,
packet_data: Vec<u8>
) -> Result<OggPage, OggReadError>
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.