pub struct BasePacketReader { /* private fields */ }
Expand description

Low level struct for reading from an Ogg stream.

Note that most times you’ll want the higher level PacketReader struct.

It takes care of most of the internal parsing and logic, you will only have to take care of handing over your data.

Essentially, it manages a cache of package data for each logical bitstream, and when the cache of every logical bistream is empty, it asks for a fresh page. You will then need to feed the struct one via the push_page function.

All functions on this struct are async ready. They get their data fed, instead of calling and blocking in order to get it.

Implementations§

source§

impl BasePacketReader

source

pub fn new() -> Self

Constructs a new blank BasePacketReader.

You can feed it data using the push_page function, and obtain data using the read_packet function.

source

pub fn read_packet(&mut self) -> Option<Packet>

Extracts a packet from the cache, if the cache contains valid packet data, otherwise it returns None.

If this function returns None, you’ll need to add a page to the cache by using the push_page function.

source

pub fn push_page(&mut self, page: OggPage) -> Result<(), OggReadError>

Pushes a given Ogg page, updating the internal structures with its contents.

If you want the code to function properly, you should first call parse_segments, then parse_packet_data on a PageParser before passing the resulting OggPage to this function.

source

pub fn update_after_seek(&mut self)

Reset the internal state after a seek

It flushes the cache so that no partial data is left inside. It also tells the parsing logic to expect little inconsistencies due to the read position not being at the start.

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.