pub struct CountingStream { /* private fields */ }Expand description
Wraps any output stream and counts bytes written.
Progress tracking is a CLI concern — streams don’t know their size. Wrap the output with CountingStream, then query bytes_written().
let mut output = CountingStream::new(libfreemkv::output(dest, &title)?);
while let Ok(Some(frame)) = input.read() {
output.write(&frame)?;
let pct = output.bytes_written() as f64 / total as f64;
}Implementations§
Trait Implementations§
Source§impl Stream for CountingStream
impl Stream for CountingStream
Source§fn read(&mut self) -> Result<Option<PesFrame>>
fn read(&mut self) -> Result<Option<PesFrame>>
Read the next frame, or
Ok(None) at end of stream. Returns
StreamWriteOnly (E9001) on a write-only sink.Source§fn write(&mut self, frame: &PesFrame) -> Result<()>
fn write(&mut self, frame: &PesFrame) -> Result<()>
Write a frame to the sink. Returns
StreamReadOnly (E9000) on a
read-only source.Source§fn finish(&mut self) -> Result<()>
fn finish(&mut self) -> Result<()>
Finalize the stream: flush buffered frames, write any container
index (MKV
Cues), close the underlying file/socket. Idempotent
for read-only streams (no-op).Source§fn info(&self) -> &DiscTitle
fn info(&self) -> &DiscTitle
Stream metadata. Stable across reads — implementors must return a
consistent reference for the lifetime of the stream.
Source§fn codec_private(&self, track: usize) -> Option<Vec<u8>>
fn codec_private(&self, track: usize) -> Option<Vec<u8>>
Codec initialization data for a track (SPS/PPS, AC-3 fscod, etc.).
None for tracks that don’t need codec_private (raw passthrough).Source§fn headers_ready(&self) -> bool
fn headers_ready(&self) -> bool
True when
codec_private is available for every video track —
callers buffer input frames until this flips, since some output
formats (MKV) can’t write frames without codec init data.Auto Trait Implementations§
impl Freeze for CountingStream
impl !RefUnwindSafe for CountingStream
impl !Send for CountingStream
impl !Sync for CountingStream
impl Unpin for CountingStream
impl UnsafeUnpin for CountingStream
impl !UnwindSafe for CountingStream
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