Expand description
Drivers that run a zencodec decoder over real input.
zencodec defines two decoder shapes that do no I/O of their own:
IncrementalDecode: resumable, driven by whoever holds the bytes (stepoffers them in place).DecodeJob::push_decoder_from_source: pull-native, reading aDynReadAt.
This crate supplies the loops and adapters that connect either shape to a slice, a random-access source, a sequential stream, or an async runtime, so neither codecs nor applications write them:
| input | resumable decoder | pull-native decoder |
|---|---|---|
| slice | drive_from_slice | SliceReadAt |
ReadAt (file, object store, FFI callback) | drive_from_read_at | direct |
std::io::Read stream (feature std) | pump_read_to_sink | BufferedReadAt |
async runtime (feature tokio) | tokio_io::decode_async | tokio_io::pull_decode_on_thread |
Cancellation and progress share one handle: every driver takes an
Option<&dyn how_far::Pulse> (Pulse: Stop), checks it each step,
tells it the row total once the header is known and advances it per
strip. A caller with only a Stop passes how_far::StopOnly::borrowed.
Every driver checks each Need against the input it just offered and
returns ProtocolViolation for a decoder that would otherwise spin.
The crate is no_std + alloc by default. The std feature adds the
stream pump, file source and buffered stream adapter; tokio adds
tokio_io (tokio::sync and tokio::io only; it never starts a
runtime).
Modules§
- destination
- Actual writer access for synchronous image and container output. Actual forward-only and seek-back destinations for synchronous output. A wrapper binds access and the output origin to the retained writer.
- row_
encode - Owned row-source encoding with policy before final-destination effects.
- storage
- Compatibility path for shared allocation ownership.
- tokio_
io - Async drivers for tokio (and any executor): decode with no thread
blocked on I/O and no
asyncin codec code.
Structs§
- Buffered
Read At ReadAtover a sequentialstd::io::Readstream, buffered per aBufferPolicy.- Collect
Sink - A sink that collects every final row into one tightly packed image.
- Controlled
Stepper - Drive a controlled decoder with
crate::SliceCursor,crate::ReadAtCursoror an async cursor, returning mandatory boundaries to the adapter. - Drive
Options - Tuning for the drivers.
- Drive
Stats - Counters from one drive.
- Encode
Write Report - What
encode_to_writerdid. - Encoder
Sink DecodeRowSinkthat feeds anEncoder.- File
Read At ReadAtover a file, using positional reads on Unix and Windows and seek + read elsewhere. Unix reads leave a shared file cursor unchanged; Windowsseek_readcan update it. No implementation usesunsafe.- IoLimits
- Limits on storage and requests owned by one input driver.
- Policy
Decoder - Connect a controlled decoder to every existing slice, file and network driver. Decisions run only at actual suspensions, before native work resumes. The decoder remains terminal after a callback failure or caught unwind.
- Read
AtCursor - Drives a stage over a random-access source.
- Read
AtReader - Adapt a positional source to
ReadandSeekwith an independent cursor. - Read
Cursor - Drives a stage over a sequential stream.
- Slice
Cursor - Drives a stage over bytes already in memory, without copying them.
- Stepped
- The result of one
ByteStepper::step. - Work
Quota - Maximum codec steps in one uninterrupted async compute turn.
Enums§
- Buffer
Policy - How a
BufferedReadAtretains bytes from a sequential stream. - Controlled
Event - A controlled decoder’s observable progress. A suspension is never completion.
- Drive
Failure - Failure of a drive over any
ByteStepper. - Encode
Write Error - Failure of
encode_to_writer. - Encoder
Sink Error - Failure of
EncoderSink::finish. - Input
Error - Driver admission or allocation failure, separate from codec/source errors.
- Policy
Decode Error - Native failure or traced application-policy failure during controlled decode.
- Protocol
Violation - A decoder broke the
IncrementalDecodeprotocol. Drivers report this instead of looping. - Pump
Failure - Failure of a drive over a sequential
std::io::Readstream. - StdSource
Error - A source-contract refusal or the original standard-library I/O failure.
- Step
- What a step produced.
- Yield
- What a cursor’s
nextreturns: an output, or the last one.
Traits§
- Byte
Stepper - A stage that consumes bytes through the sans-I/O dialogue.
Functions§
- coalesce_
byte_ ranges - Merge overlapping or near-adjacent ranges (gap
<= max_gap) into one. - coalesce_
into coalesce_byte_rangeswriting intoout(cleared first), so a loop reuses one allocation.- drive_
from_ read_ at - Run
decoderover a random-access source. - drive_
from_ slice - Run
decoderover an in-memory image without copying it. - encode_
to_ writer Deprecated - Encode
pixelsintow, sending bytes as the encoder produces them. - pump_
read_ to_ sink - Pump a sequential stream into
decoder, writing rows intosink. - write_
pending - Write every byte
enchas pending tow, then consume it. Returns how many bytes were written. - write_
pending_ animation write_pendingfor anAnimationFrameEncoder: write the bytes of the frames pushed so far.
Type Aliases§
- Drive
Error - Failure of an image drive: a
DriveFailurewhose stage error is the decoder’sStepError. - Pump
Error - Failure of
pump_read_to_sink: aPumpFailurewhose stage error is the decoder’sStepError.