pub struct Writer<W> { /* private fields */ }Expand description
Stateful MP4 writer that can backfill container sizes after payload bytes are written.
This wrapper is designed for rewrite-style flows that need to stream payload bytes, nest container boxes, and then patch final sizes back into previously written headers.
Implementations§
Source§impl<W> Writer<W>
impl<W> Writer<W>
Sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Consumes the wrapper and returns the underlying writer.
Source§impl<W> Writer<W>
impl<W> Writer<W>
Sourcepub fn start_box_type(
&mut self,
box_type: FourCc,
) -> Result<BoxInfo, WriterError>
pub fn start_box_type( &mut self, box_type: FourCc, ) -> Result<BoxInfo, WriterError>
Starts a new box using box_type and an empty small-header placeholder.
The final size is written later by Writer::end_box.
Sourcepub fn start_box(&mut self, info: BoxInfo) -> Result<BoxInfo, WriterError>
pub fn start_box(&mut self, info: BoxInfo) -> Result<BoxInfo, WriterError>
Writes info as the next box header and pushes it onto the open-box stack.
Callers typically pass either a small-header placeholder or a header copied from an existing box when preserving layout details.
Source§impl<W> Writer<W>where
W: AsyncWriteSeek,
impl<W> Writer<W>where
W: AsyncWriteSeek,
Sourcepub async fn start_box_type_async(
&mut self,
box_type: FourCc,
) -> Result<BoxInfo, WriterError>
Available on crate feature async only.
pub async fn start_box_type_async( &mut self, box_type: FourCc, ) -> Result<BoxInfo, WriterError>
async only.Starts a new box through the additive Tokio-based async library surface using box_type
and an empty small-header placeholder.
The final size is written later by Writer::end_box_async.
Sourcepub async fn start_box_async(
&mut self,
info: BoxInfo,
) -> Result<BoxInfo, WriterError>
Available on crate feature async only.
pub async fn start_box_async( &mut self, info: BoxInfo, ) -> Result<BoxInfo, WriterError>
async only.Writes info as the next box header through the additive Tokio-based async library
surface and pushes it onto the open-box stack.
Sourcepub async fn end_box_async(&mut self) -> Result<BoxInfo, WriterError>
Available on crate feature async only.
pub async fn end_box_async(&mut self) -> Result<BoxInfo, WriterError>
async only.Rewrites the most recently opened box header with its final size through the additive Tokio-based async library surface.
The returned BoxInfo reflects the finalized on-disk size after the rewrite completes.
Sourcepub async fn copy_box_async<R>(
&mut self,
reader: &mut R,
info: &BoxInfo,
) -> Result<(), WriterError>where
R: AsyncReadSeek,
Available on crate feature async only.
pub async fn copy_box_async<R>(
&mut self,
reader: &mut R,
info: &BoxInfo,
) -> Result<(), WriterError>where
R: AsyncReadSeek,
async only.Copies the exact byte range described by info into the current output position through
the additive Tokio-based async library surface.
Trait Implementations§
Source§impl<W> AsyncWrite for Writer<W>where
W: AsyncWrite + Unpin,
Available on crate feature async only.
impl<W> AsyncWrite for Writer<W>where
W: AsyncWrite + Unpin,
async only.Source§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize>>
buf into the object. Read moreSource§fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
Source§fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
Source§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>
poll_write, except that it writes from a slice of buffers. Read moreSource§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
poll_write_vectored
implementation. Read moreSource§impl<W> Seek for Writer<W>where
W: Seek,
impl<W> Seek for Writer<W>where
W: Seek,
Source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
1.55.0 · Source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
seek_stream_len)Source§impl<W> Write for Writer<W>where
W: Write,
impl<W> Write for Writer<W>where
W: Write,
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)