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 readiness;
24pub mod ring;
25#[cfg(unix)]
26pub mod shm;
27pub mod sync;
28
29pub mod id {
30    //! Re-export of the standalone `netid64` primitive.
31
32    pub use netid64::{NetId64, ParseNetId64Error};
33}
34
35#[cfg(unix)]
36pub mod ring_shm {
37    //! Compatibility module for the pre-`ring::shm` layout.
38    pub use crate::ring::shm::*;
39}
40
41pub use epoch::OrbitEpoch;
42pub use error::{Error, Result};
43#[cfg(unix)]
44pub use fleet::FleetObserver;
45pub use fleet::{Fleet, NodeId};
46pub use id::{NetId64, ParseNetId64Error};
47#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "macos"))]
48pub use ring::RingEventFd;
49pub use ring::cursor::{RingCursor, RingFrameSource, RingLoss, RingPoll, RingRead, poll_ring};
50#[cfg(unix)]
51pub use ring::shm::{ShmRingLaneView, ShmRingMetadata, ShmRingView};
52pub use ring::{Frame, Ring, RingSpec, RingTopology};
53
54/// Marker for a type that has a stable wire identity across the fleet.
55///
56/// Required bounds:
57/// - `Clone` — values may be delivered to multiple subscribers / nodes.
58/// - `Send + Sync + 'static` — values cross thread / process boundaries.
59pub trait OrbitTyped: Clone + Send + Sync + 'static {
60    /// Stable wire identifier. Hand-picked in V0; build.rs-generated later.
61    const KIND: u8;
62
63    /// Ring layout and retention policy for this wire kind.
64    ///
65    /// This is part of the cross-process wire contract. Reusing a KIND
66    /// with a different spec is an error.
67    const RING_SPEC: RingSpec;
68}