Struct OggStreamWriter

Source
pub struct OggStreamWriter<W>
where W: Write + Debug,
{ pub writer: W, pub stream_id: u32, pub packet_index: u32, pub cur_packet: OggPacket, pub granule_position: u64, pub on_seal: Box<dyn FnMut(usize) -> u64>, pub bytes_written: u64, }
Expand description
  • An ogg packets writer sink

Fields§

§writer: W
  • The writer, when a packet is full or you want to seal the packet, the packet is flushed in the writer
§stream_id: u32
  • The unique stream ID for a whole stream. Programs use the stream ID to identify which packet is for which stream.
§packet_index: u32
  • The packet index.
§cur_packet: OggPacket
  • The current packet, ready to be written.
§granule_position: u64
  • The granule position is for the programmers to reference it for some purpose.
§on_seal: Box<dyn FnMut(usize) -> u64>
  • The OggStreamWriter<W> implements Write, when the cur_packet is full, the on_seal() closure will be called for updating the granule position.
  • And then the packet will be flushed into the writer.
§bytes_written: u64
  • How many bytes were written into this stream.

Implementations§

Source§

impl<W> OggStreamWriter<W>
where W: Write + Debug,

Source

pub fn new(writer: W, stream_id: u32) -> Self

Source

pub fn set_granule_position(&mut self, position: u64)

  • Set the granule position. This field of data is not used by the Ogg stream.
  • The granule position is for the inner things to reference it for some purpose.
Source

pub fn get_granule_position(&self) -> u64

  • Get the granule position you had set before
Source

pub fn mark_cur_packet_as_end_of_stream(&mut self)

  • Mark the current packet as EOS
Source

pub fn get_bytes_written(&self) -> u64

  • Get how many bytes written in this stream
Source

pub fn set_on_seal_callback(&mut self, on_seal: Box<dyn FnMut(usize) -> u64>)

  • Set a callback for the Write trait when it seals the packet, the callback helps with updating the granule position
Source

pub fn reset(&mut self)

  • Reset the stream state, discard the packet, reinit the packet to a BOS
Source

pub fn seal_packet( &mut self, granule_position: u64, is_end_of_stream: bool, ) -> Result<()>

  • Save the current packet and write it to the sink, then create a new packet for writing.

Trait Implementations§

Source§

impl<W> Debug for OggStreamWriter<W>
where W: Write + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<W> Drop for OggStreamWriter<W>
where W: Write + Debug,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<W> Write for OggStreamWriter<W>
where W: Write + Debug,

Source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

Writes a buffer into this writer, returning how many bytes were written. Read more
Source§

fn flush(&mut self) -> Result<()>

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
1.36.0 · Source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
Source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
1.0.0 · Source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

Attempts to write an entire buffer into this writer. Read more
Source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations§

§

impl<W> Freeze for OggStreamWriter<W>
where W: Freeze,

§

impl<W> !RefUnwindSafe for OggStreamWriter<W>

§

impl<W> !Send for OggStreamWriter<W>

§

impl<W> !Sync for OggStreamWriter<W>

§

impl<W> Unpin for OggStreamWriter<W>
where W: Unpin,

§

impl<W> !UnwindSafe for OggStreamWriter<W>

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

Source§

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

Source§

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.