Skip to main content

parallax/
lib.rs

1//! # Parallax
2//!
3//! A Rust-native streaming pipeline engine with zero-copy multi-process support.
4//!
5//! Parallax provides both dynamic (runtime-configured) and typed (compile-time safe)
6//! pipeline construction, with buffers backed by shared memory for efficient
7//! multi-process communication.
8//!
9//! ## Features
10//!
11//! - **Zero-copy buffers**: memfd-backed arenas with cross-process reference counting
12//! - **Progressive typing**: Start dynamic, graduate to typed
13//! - **Multi-process pipelines**: memfd + Unix socket IPC (SCM_RIGHTS)
14//! - **Hybrid scheduling**: Tokio tasks + dedicated real-time threads
15//! - **rkyv serialization**: Zero-copy deserialization at network boundaries
16//! - **Linux-only**: memfd_create, huge pages, eventfd, DMA-BUF
17//!
18//! ## Quick Start
19//!
20//! ```rust,ignore
21//! use parallax::prelude::*;
22//! use parallax::typed::{pipeline, from_iter, map, filter, collect};
23//!
24//! // Dynamic pipeline (string syntax)
25//! let mut pipeline = Pipeline::parse("videotestsrc num-buffers=60 ! videoconvert ! nullsink")?;
26//! pipeline.run().await?;
27//!
28//! // Dynamic pipeline (programmatic)
29//! let mut pipeline = Pipeline::new();
30//! let src = pipeline.add_source("src", my_source);   // impl Source
31//! let sink = pipeline.add_sink("sink", my_sink);     // impl Sink
32//! pipeline.link(src, sink)?;
33//! pipeline.run().await?;
34//!
35//! // Typed pipeline (compile-time checked)
36//! let source = from_iter(vec![1, 2, 3, 4, 5]);
37//! let result = pipeline(source)
38//!     .then(filter(|x: &i32| x % 2 == 0))
39//!     .then(map(|x: i32| x * 10))
40//!     .sink(collect::<i32>())
41//!     .run()?
42//!     .into_inner();
43//! // result: [20, 40]
44//! ```
45
46#![warn(missing_docs)]
47#![warn(clippy::all)]
48#![deny(unsafe_op_in_unsafe_fn)]
49// Allow these clippy lints that are intentional design choices
50#![allow(clippy::too_many_arguments)] // Complex functions in scheduler/executor
51#![allow(clippy::type_complexity)] // Complex types in typed pipelines and executor returns
52#![allow(clippy::result_large_err)] // Buffer returned in Err for ring buffer full case
53
54pub mod buffer;
55pub mod clock;
56pub mod codec;
57pub mod control;
58pub mod converters;
59pub mod element;
60pub mod elements;
61pub mod error;
62pub mod event;
63pub mod format;
64pub mod gpu;
65pub mod link;
66pub mod memory;
67pub mod metadata;
68pub mod negotiation;
69pub mod observability;
70pub mod pipeline;
71pub mod plugin;
72pub mod temporal;
73pub mod typed;
74
75/// Prelude for convenient imports
76pub mod prelude {
77    pub use crate::buffer::Buffer;
78    pub use crate::clock::{
79        Clock, ClockFlags, ClockProvider, ClockTime, PipelineClock, SystemClock,
80    };
81    pub use crate::element::{
82        AsyncElementDyn, AsyncSink, AsyncSource, AsyncTransform, DynAsyncElement, Element, Output,
83        Sink, Source, Transform,
84    };
85    pub use crate::error::{Error, Result};
86    pub use crate::event::{Event, PipelineItem, TagList};
87    pub use crate::format::{
88        AudioFormat, Caps, ElementMediaCaps, FormatMemoryCap, MediaCaps, MediaFormat, RtpFormat,
89        VideoFormat,
90    };
91    pub use crate::memory::{MemorySegment, MemoryType};
92    pub use crate::metadata::{BufferFlags, Metadata, RtpMeta};
93    pub use crate::pipeline::{Executor, Pipeline};
94}
95
96pub use error::{Error, Result};