oxideav_source/lib.rs
1//! Source registry shim — `oxideav_core::SourceRegistry` plus the
2//! built-in `file://` driver and a prefetching `BufferedSource`
3//! wrapper.
4//!
5//! `SourceRegistry`, `OpenSourceFn`, and `ReadSeek` now live in
6//! `oxideav-core` (so the unified `RuntimeContext` can hold the source
7//! registry alongside codec / container / filter). This crate retains
8//! the concrete `file://` driver and the `BufferedSource` helper that
9//! `oxideav-http` and the player rely on; it also exposes a
10//! [`with_defaults`] free function that pre-populates a registry with
11//! the file driver, matching the historical surface.
12//!
13//! ```no_run
14//! let reg = oxideav_source::with_defaults();
15//! let _input = reg.open("/tmp/video.mp4").unwrap();
16//! ```
17
18pub use oxideav_core::{OpenSourceFn, ReadSeek, SourceRegistry};
19
20mod buffered;
21mod file;
22mod uri;
23
24pub use buffered::BufferedSource;
25pub use file::open_file;
26
27/// Build a [`SourceRegistry`] pre-populated with the built-in `file`
28/// driver. Bare paths (without a scheme) also dispatch to it via the
29/// registry's fall-back behaviour.
30pub fn with_defaults() -> SourceRegistry {
31 let mut r = SourceRegistry::new();
32 r.register("file", open_file);
33 r
34}
35
36/// Install the `file://` (and bare-path) source driver into the given
37/// runtime context. Idempotent — replacing a prior registration of the
38/// `file` scheme.
39pub fn register(ctx: &mut oxideav_core::RuntimeContext) {
40 ctx.sources.register("file", open_file);
41}