Expand description
§styx (facade crate)
The end-user entry point that re-exports the layered stack (styx-core, styx-capture, styx-codec, optional backends) behind a single prelude. It adds a capture API, pipeline builder, metrics, probing helpers, and feature-gated preview support.
§Documentation
§Install
[dependencies]
styx = "0.1.0"§What it provides
styx::prelude: re-exports core/capture/codec preludes plus capture API (CaptureRequest,CaptureHandle,StyxConfig,start_capture,set_capture_tunables, etc.), pipeline types (MediaPipelineBuilder,MediaPipeline), metrics, and backend handles.probe_all: merge v4l2/libcamera probe results when enabled.BackendHandle/BackendKind,ProbedDevice,ProbedBackend: describe discovered devices and selected backends.capture_api: helpers for synthetic backends (make_netcam_device,make_file_device) and tunables.session:MediaPipelinefor capture→decode→hook→encode flows (sync-first; async helpers whenasyncis enabled).preview(featurepreview-window): simple RGBA/RGB preview window for examples.
§Typical usage
Capture with a chosen backend/mode:
ⓘ
use styx::prelude::*;
let devices = probe_all();
let device = devices.first().expect("no devices");
let handle = CaptureRequest::new(device)
.backend_preferred(Some(BackendKind::Virtual)) // or V4l2/Libcamera when enabled
.start()?;
match handle.recv() {
RecvOutcome::Data(frame) => println!("got frame {:?}", frame.meta().format),
RecvOutcome::Empty => {}
RecvOutcome::Closed => {}
}
handle.stop();Capture → decode pipeline with hooks and optional preview:
ⓘ
use std::sync::Arc;
use styx::prelude::*;
let device = /* virtual or probed device */;
let decoder = Arc::new(PassthroughDecoder::new(device.backends[0].descriptor.modes[0].format.code));
let mut pipeline = MediaPipelineBuilder::new(CaptureRequest::new(device))
.decoder(decoder)
.frame_hook(|frame| frame) // works on FrameLease
.hook(|img| img.flipv()) // DynamicImage hook (feature `hooks`)
.start()?;
while let RecvOutcome::Data(frame) = pipeline.next() {
println!("pipeline frame {:?}", frame.meta().format);
}Global tunables for queues/pools/netcam backoff:
ⓘ
use styx::prelude::*;
StyxConfig::new()
.capture_queue_depth(8)
.capture_pool(4, 1 << 20, 8)
.netcam_timeouts(10)
.apply();§Examples
All examples live in crates/styx/examples and are runnable from this crate; see the workspace README for the full list and required feature flags.
Re-exports§
pub use styx_capture as capture;pub use styx_codec as codec;pub use styx_core as core;pub use thiserror;
Modules§
- capture_
api - Capture helpers, request builders, and backend constructors.
- prelude
- session
- Unified pipeline that wires capture, decode, hook, and encode in one object.
Structs§
- Device
Identity - Physical device identity derived from fingerprints/props.
- Probe
Result - Probe result that includes any backend errors encountered.
- Probed
Backend - Backend-specific entry for a probed device.
- Probed
Device - Unified device descriptor for probed backends.
Enums§
- Backend
Handle - Backend-specific handle used for configuration/streaming.
- Backend
Kind - Known backend kinds.
Functions§
- probe_
all - Probe all enabled backends and return a merged list.
- probe_
all_ with_ errors - Probe all enabled backends and include any probe errors.