pub struct OggStreamWriter<W>{
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>
implementsWrite
, when thecur_packet
is full, theon_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>
impl<W> OggStreamWriter<W>
pub fn new(writer: W, stream_id: u32) -> Self
Sourcepub fn set_granule_position(&mut self, position: u64)
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.
Sourcepub fn get_granule_position(&self) -> u64
pub fn get_granule_position(&self) -> u64
- Get the granule position you had set before
Sourcepub fn mark_cur_packet_as_end_of_stream(&mut self)
pub fn mark_cur_packet_as_end_of_stream(&mut self)
- Mark the current packet as EOS
Sourcepub fn get_bytes_written(&self) -> u64
pub fn get_bytes_written(&self) -> u64
- Get how many bytes written in this stream
Sourcepub fn set_on_seal_callback(&mut self, on_seal: Box<dyn FnMut(usize) -> u64>)
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
Trait Implementations§
Source§impl<W> Debug for OggStreamWriter<W>
impl<W> Debug for OggStreamWriter<W>
Source§impl<W> Drop for OggStreamWriter<W>
impl<W> Drop for OggStreamWriter<W>
Source§impl<W> Write for OggStreamWriter<W>
impl<W> Write for OggStreamWriter<W>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
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<()>
fn flush(&mut self) -> Result<()>
Flushes this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
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>
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
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more