| Crates.io | styx-core-rs |
| lib.rs | styx-core-rs |
| version | 0.1.0 |
| created_at | 2026-01-19 11:58:34.360685+00 |
| updated_at | 2026-01-19 11:58:34.360685+00 |
| description | Core zero-copy buffers, formats, queues, and controls for Styx. |
| homepage | https://github.com/sozo/Styx |
| repository | https://github.com/sozo/Styx |
| max_upload_size | |
| id | 2054419 |
| size | 53,391 |
Core primitives shared across the stack: buffer pools, frame leases/layouts, bounded queues, FourCc/format types, controls, and lightweight metrics.
[dependencies]
styx-core-rs = "0.1.0"
buffer: BufferPool, BufferLease, FrameLease, plane views, and helpers like plane_layout_from_dims/plane_layout_with_stride.queue: bounded/newest/unbounded queues with backpressure-aware SendOutcome/RecvOutcome.format: FourCc, Resolution, MediaFormat, Interval/IntervalStepwise, and ColorSpace.controls: ControlId, ControlMeta, ControlValue, and validation logic.metrics: simple hit/miss/allocation counters for pools.Frames are built from pooled buffers to avoid churn:
use styx_core::prelude::*;
let pool = BufferPool::with_limits(4, 1 << 20, 8);
let res = Resolution::new(640, 480).unwrap();
let layout = plane_layout_from_dims(res.width, res.height, 3);
let meta = FrameMeta::new(MediaFormat::new(FourCc::new(*b"RG24"), res, ColorSpace::Srgb), 0);
let frame = FrameLease::single_plane(meta, pool.lease(), layout.len, layout.stride);
FrameLease exposes immutable/mutable plane views and returns buffers to the pool on drop. Use planes_mut for in-place writes; multi-plane layouts are supported via FrameLease::multi_plane.
queue::bounded provides a non-blocking bounded channel:
use styx_core::prelude::*;
let (tx, rx) = bounded::<FrameLease>(4);
match tx.send(frame) {
SendOutcome::Sent => {},
SendOutcome::Closed => {},
SendOutcome::Full(f) => { /* backpressure */ }
}
match rx.recv() {
RecvOutcome::Data(frame) => { /* consume */ }
RecvOutcome::Empty => { /* try again */ }
RecvOutcome::Closed => {}
}
MediaFormat bundles FourCc, resolution, and color space; Interval describes frame pacing; ControlMeta + ControlValue carry backend controls with validation helpers.