pub struct Output { /* private fields */ }Expand description
A pipeline with its output format chosen, ready to be pulled.
Nothing has executed yet: the terminals on this type are what pull pixels through the graph.
Implementations§
Source§impl Output
impl Output
Sourcepub const fn options(&self) -> EncodeOptions
pub const fn options(&self) -> EncodeOptions
The encoder options in effect.
Sourcepub const fn threads(self, threads: usize) -> Self
pub const fn threads(self, threads: usize) -> Self
Run this pipeline on threads worker threads.
Zero, the default, means one per available core. Setting it to one gives a fully deterministic serial run, which is what the differential tests against the reference evaluator use.
Sourcepub fn with_scheduler(self, scheduler: Arc<Scheduler>) -> Self
pub fn with_scheduler(self, scheduler: Arc<Scheduler>) -> Self
Run on scheduler, shared with other pipelines, instead of a pool of
this run’s own.
A server or a runtime should build one Scheduler at startup and
pass it to every output: otherwise each run spawns a thread per core
and joins them when it ends, and concurrent requests each bring their
own, oversubscribing the machine. Many pipelines may run on one
scheduler at once, from any threads. Output::threads and
Output::scheduler_options are ignored when one is set: the
scheduler was configured when it was built.
Sourcepub const fn scheduler_options(self, options: SchedulerOptions) -> Self
pub const fn scheduler_options(self, options: SchedulerOptions) -> Self
Tune the scheduler directly.
Sourcepub fn write(self, sink: impl Sink) -> Result<()>
pub fn write(self, sink: impl Sink) -> Result<()>
Run the pipeline, streaming encoded bytes into sink.
Rows are encoded and written in order as they are produced. A failure
anywhere fails the whole call; partial output is never reported as
success (ARCHITECTURE §Failure model), though bytes already handed to
sink are of course already gone — a caller needing all-or-nothing
should write to a buffer or a temporary and commit on success.
§Errors
Returns PixelsError::Unsupported if the format has no encoder in
this build, and otherwise any error from the pipeline or the sink.
Sourcepub fn write_with_stats(self, sink: impl Sink) -> Result<RunStats>
pub fn write_with_stats(self, sink: impl Sink) -> Result<RunStats>
Stream to sink, reporting what the run did.
The same work as Output::write, with RunStats returned instead
of discarded. Use it to confirm a pipeline streamed rather than
materialized, or that a JPEG thumbnail took the shrink-on-load path:
stats.reduction is None when the source decoded at full size, which
is the difference between a fast thumbnail and a slow one.
§Errors
As Output::write.
Sourcepub fn bytes_via_reference(self) -> Result<Vec<u8>>
pub fn bytes_via_reference(self) -> Result<Vec<u8>>
Run the pipeline through the reference evaluator instead of the tile scheduler, collecting encoded bytes.
The reference evaluator is single-threaded and whole-image: it holds every intermediate in full, so it is slow and its memory scales with the image. It exists because it is obviously correct, which makes it the oracle the scheduler is verified against — the two must produce byte-identical output for every pipeline (ROADMAP M2).
Use it to verify, to debug a suspected scheduler bug, or where an image
is small and determinism matters more than throughput. Prefer
Output::bytes otherwise.
§Errors
As Output::bytes.