Struct ogg::reading::PacketReader

source ·
pub struct PacketReader<T: Read + Seek> { /* private fields */ }
Expand description

Reader for packets from an Ogg stream.

This reads codec packets belonging to several different logical streams from one physical Ogg container stream.

This reader is not async ready. It does not keep its internal state consistent when it encounters the WouldBlock error kind. If you desire async functionality, consider enabling the async feature and look into the async module.

Implementations§

source§

impl<T: Read + Seek> PacketReader<T>

source

pub fn new(rdr: T) -> PacketReader<T>

Constructs a new PacketReader with a given Read.

source

pub fn into_inner(self) -> T

Returns the wrapped reader, consuming the PacketReader.

source

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

Reads a packet, and returns it on success.

Ok(None) is returned if the physical stream has ended.

source

pub fn read_packet_expected(&mut self) -> Result<Packet, OggReadError>

Reads a packet, and returns it on success.

The difference to the read_packet function is that this function returns an Err(_) if the physical stream has ended. This function is useful if you expect a new packet to come.

source

pub fn seek_bytes(&mut self, pos: SeekFrom) -> Result<u64, Error>

Seeks the underlying reader

Seeks the reader that this PacketReader bases on by the specified number of bytes. All new pages will be read from the new position.

This also flushes all the unread packets in the queue.

source

pub fn seek_absgp( &mut self, stream_serial: Option<u32>, pos_goal: u64 ) -> Result<bool, OggReadError>

Seeks to absolute granule pos

More specifically, it seeks to the first Ogg page that has an absgp greater or equal to the specified one. In the case of continued packets, the seek operation may also end up at the last page that comes before such a page and has a packet start.

The passed stream_serial parameter controls the stream serial number to filter our search for. If it’s None, no filtering is applied, but if it is Some(n), we filter for streams with the serial number n. Note that the None case is only intended for streams where only one logical stream exists, the seek may misbehave if None gets passed when multiple streams exist.

The returned bool indicates whether the seek was successful.

source

pub fn delete_unread_packets(&mut self)

Resets the internal state by deleting all unread packets.

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for PacketReader<T>
where T: RefUnwindSafe,

§

impl<T> Send for PacketReader<T>
where T: Send,

§

impl<T> Sync for PacketReader<T>
where T: Sync,

§

impl<T> Unpin for PacketReader<T>
where T: Unpin,

§

impl<T> UnwindSafe for PacketReader<T>
where T: UnwindSafe,

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.