Skip to main content

Module output

Module output 

Source
Expand description

Checked synchronous output drivers (requires std). Checked synchronous container output for forward writers and seekable files.

PreparedOutput::new requires exact packet timing and owns the actual begun muxer and destination without publishing its header. PreparedOutput::publish consumes that preparation. Output::new combines those steps for callers that do not need a policy decision between them. Unsupported timing is an error, never a fallback to container-chosen timing.

use zencodec_media::{container::Muxer, output::{Failure, Forward, Output, Stats},
    packet::Packet, track::TrackInfo};
fn write<M: Muxer, W: std::io::Write>(
    muxer: M, writer: W, tracks: &[TrackInfo], packets: impl IntoIterator<Item = Packet>,
) -> Result<Stats, Failure> {
    let mut output = Output::new(muxer, Forward(writer), tracks, None)?;
    for packet in packets { output.send(packet, None)?; }
    output.finish(None)
}

To ask policy before any write, replace Output::new with PreparedOutput::new, retain the result while deciding, then call PreparedOutput::publish. Use SeekBack::new instead of Forward for a file whose current position is the start of this output.

These drivers may block on Write. Byte availability does not establish safe encoder backpressure: finish or separately qualify upstream raw-buffer retention before sending packets to a slow writer. No whole-operation memory bound is implied. Dropping either state does not implicitly finish or publish. None for a borrowed Pulse adds no per-call control and preserves native retained controls, timing validation and destination checks.

Structs§

Failure
Terminal failure with original cause and confirmed append progress. emitted excludes overwrites; a failed patch may have partial effects.
Forward
Shared destination wrappers; media and raster routes use the same origin rules. Forward-only output, including sockets and other Write implementations.
Output
Active output driver. Any send failure or unwind makes further sends fail. finish consumes the driver; dropping it never retries effects.
PreparedOutput
Owns the actual begun muxer and destination without publishing its header. Dropping it abandons only private preparation. Publication consumes the token.
SeekBack
Shared destination wrappers; media and raster routes use the same origin rules. Seekable output whose offsets are relative to the writer’s initial position. Existing prefixes remain outside all output patches.
Stats
Successful output progress; byte counts are not memory measurements.

Enums§

Stage
Stage at which output stopped.

Traits§

Destination
Shared destination wrappers; media and raster routes use the same origin rules. Writer access derived by wrapping an actual writer in Forward or SeekBack. Sealed so callers cannot invent seek support independently of the writer.