Expand description
Source registry shim — oxideav_core::SourceRegistry plus the
built-in file://, mem://, data:, and concat: drivers and a
prefetching BufferedSource wrapper.
SourceRegistry, the typed source traits (BytesSource,
PacketSource, FrameSource), and the SourceOutput enum
live in oxideav-core. This crate retains the concrete drivers and
the BufferedSource helper that oxideav-http and the player rely
on; it also exposes a with_defaults free function that
pre-populates a registry with the bundled drivers, matching the
historical surface.
let reg = oxideav_source::with_defaults();
let _input = reg.open("/tmp/video.mp4").unwrap();§Schemes
file://<path>and bare paths — local filesystem. Default opener is unscoped; install aFileScopeviaFileScope::register_intoto restrict by directory allow-list.mem://<id>— process-global in-memory buffer; register a payload withmem::put.data:[<mediatype>][;base64],<bytes>— RFC 2397 inline byte literals; payload is decoded directly from the URI with no filesystem access.concat:<a>|<b>|…— concatenate severalfile://segments into one seekable byte stream (de-factoconcat:shape; no on-wire spec).slice:<offset>+<length>!<inner-uri>— URI-level windowed view over an innerfile:///mem:///data:/slice:source. Pipelines can address a byte-range sub-stream without first materialising the inner source.
Re-exports§
pub use data::open_data;pub use data::parse as parse_data_uri;pub use data::DataUri;pub use mem::open_mem;
Modules§
- data
- Built-in
data:driver — inline byte literals embedded in the URI. - mem
- Built-in
mem://driver — in-memory synthetic byte buffers.
Structs§
- Buffered
Source - Buffered, prefetching wrapper around any
ReadSeek. - Buffered
Source Builder - Builder for
BufferedSource. Exposes every prefetch tunable for callers whose source has a non-default latency or transfer profile; callers that just want a sensible buffer can stay onBufferedSource::new. - File
Scope - Configurable allow-list for
file://opens. - Source
Registry - Registry mapping URI schemes to opener functions. Each scheme picks
one of three opener kinds (bytes / packets / frames) at registration
time; callers see the choice via the
SourceOutputvariant returned fromopen. - SubSource
- Windowed view over an inner
BytesSource.
Enums§
- Source
Output - What a
SourceRegistry::opencall returns. The variant is decided at driver-registration time, so callers can match on the shape and branch the pipeline accordingly.
Constants§
- DEFAULT_
BLOCK - Default worker block size in bytes (
block_size). - DEFAULT_
LOOKBACK_ DEN - Default lookback fraction denominator. See
DEFAULT_LOOKBACK_NUM. - DEFAULT_
LOOKBACK_ NUM - Default lookback fraction numerator. The ring keeps the most recent
capacity * LOOKBACK_NUM / LOOKBACK_DENbytes behind the reader so a short back-seek hits the ring instead of restarting prefetch. The default 1/8 (~12.5 %) matches the historical hardcoded value. - DEFAULT_
PREFETCH_ TIMEOUT - Default reader-side prefetch wait timeout. A read that has to wait
for the worker longer than this surfaces
io::ErrorKind::TimedOutinstead of hanging forever; useful when the inner source has stalled (e.g. a frozen HTTP connection).
Traits§
- Bytes
Source - A seekable byte stream (
Read + Seek + Send). Replaces the historicalBox<dyn ReadSeek>opener-return type with a name that mirrors the other source-shape traits in this module. Blanket-implemented for every type that satisfies the bounds, so existing readers (files,Cursor<Vec<u8>>, HTTP-over-Range adapters) work unchanged. - Frame
Source - A producer of already-decoded
Frames. - Packet
Source - A producer of already-demuxed
Packets. - Read
Seek - Convenience trait bundle for seekable readers.
Functions§
- open_
concat - Open a
concat:<a>|<b>|…URI as a singleBytesSourcethat reads the segments back-to-back. Each segment may be a bare path, afile://URL, amem://<id>reference, adata:literal, or aslice:URI. - open_
file - Open a local file as a
Box<dyn BytesSource>. Accepts: - open_
file_ scoped - Free-function opener compatible with
SourceRegistry::register_bytes. Looks up the active scope and delegates. If no scope is installed, every call errors — install viaFileScope::register_intofirst. - open_
slice - Open a
slice:<offset>+<length>!<inner-uri>URI. - register
- Install the bundled source drivers (
file://, bare paths,mem://,data:,concat:,slice:) into the given runtime context. Idempotent — replacing any prior registration of those schemes. - stream_
len - Probe the total length of a seekable source non-destructively:
remembers the current position, seeks to
End(0), and restores the position before returning. Useful in any code path that wants the inner length once and doesn’t care about reading the bytes. - with_
defaults - Build a
SourceRegistrypre-populated with the built-infile,mem,data,concat, andslicedrivers. Bare paths (without a scheme) dispatch to thefiledriver via the registry’s fall-back behaviour.