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