Skip to main content

orbit_core/
lib.rs

1//! # `orbit-core` — fleet-aware shared memory
2//!
3//! ## What this crate is
4//!
5//! Fleet-shared same-host runtime storage between workers.
6//!
7//! Every process that joins the fleet is an equal member. There is no master,
8//! no worker — only peers. Whatever role distinction matters to the embedder
9//! is the embedder's concern; not Orbit's. Independent observers can instead
10//! attach existing SHM rings read-only, without becoming members.
11//!
12//! ## Status — first light (V0)
13//!
14//! V0 ships fixed-capacity append logs and current-state tables with POSIX
15//! shared-memory backing on Unix. Semantic layers choose the shape that
16//! matches their data: history belongs in rings; current leases do not.
17
18#[doc(hidden)]
19pub mod compile;
20pub mod epoch;
21pub mod error;
22pub mod fleet;
23pub mod process;
24pub mod readiness;
25pub mod ring;
26#[cfg(unix)]
27pub mod shm;
28pub mod sync;
29
30pub mod id {
31    //! Re-export of the standalone `netid64` primitive.
32
33    pub use netid64::{NetId64, ParseNetId64Error};
34}
35
36#[cfg(unix)]
37pub mod ring_shm {
38    //! Compatibility module for the pre-`ring::shm` layout.
39    pub use crate::ring::shm::*;
40}
41
42pub use epoch::OrbitEpoch;
43pub use error::{Error, Result};
44#[cfg(unix)]
45pub use fleet::FleetObserver;
46pub use fleet::{Fleet, FleetName, InvalidFleetName, NodeId};
47pub use id::{NetId64, ParseNetId64Error};
48#[cfg(any(
49    target_os = "linux",
50    target_os = "freebsd",
51    target_os = "macos"
52))]
53pub use ring::RingEventFd;
54pub use ring::cursor::{
55    RingCursor, RingFrameSource, RingLoss, RingPoll, RingRead, poll_ring,
56};
57#[cfg(unix)]
58pub use ring::shm::{ShmRingLaneView, ShmRingMetadata, ShmRingView};
59pub use ring::{Frame, Ring, RingSpec, RingTopology};
60
61/// Marker for a type that has a stable wire identity across the fleet.
62///
63/// Required bounds:
64/// - `Clone` — values may be delivered to multiple subscribers / nodes.
65/// - `Send + Sync + 'static` — values cross thread / process boundaries.
66pub trait OrbitTyped: Clone + Send + Sync + 'static {
67    /// Stable wire identifier. Hand-picked in V0; build.rs-generated later.
68    const KIND: u8;
69
70    /// Ring layout and retention policy for this wire kind.
71    ///
72    /// This is part of the cross-process wire contract. Reusing a KIND
73    /// with a different spec is an error.
74    const RING_SPEC: RingSpec;
75}