1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright 2026 Photon Ring Contributors
// SPDX-License-Identifier: Apache-2.0
//! # Photon Ring
//!
//! Ultra-low-latency SPMC/MPMC pub/sub using stamped ring buffers.
//!
//! `no_std` compatible (requires `alloc`). The [`topology`] module uses
//! OS threads and is available on Linux, macOS, Windows, and other
//! supported platforms.
//!
//! ## Key design
//!
//! - **Seqlock per slot** — stamp and payload share a cache line; readers never
//! take a lock, writers never allocate.
//! - **`T: Pod`** — restricts payloads to plain-old-data types where every bit
//! pattern is valid, making torn seqlock reads harmless (no UB).
//! - **Per-consumer cursor** — zero contention between subscribers.
//! - **Single-producer** — no write-side synchronisation; the seqlock invariant
//! is upheld by `&mut self` on [`Publisher::publish`].
//! - **`atomic-slots` feature** — formally sound variant that uses `AtomicU64` stripes
//! instead of `write_volatile`. Zero cost on x86-64. See the `atomic-slots` feature flag.
//! - **Arbitrary capacity** — any ring size >= 2 via Lemire fastmod; power-of-two
//! uses bitwise AND (zero regression).
//! - **Companion crates** — [`photon-ring-async`] for runtime-agnostic async wrappers,
//! [`photon-ring-metrics`] for framework-agnostic observability.
//!
//! ## Quick start
//!
//! ```
//! // Low-level SPMC channel
//! let (mut pub_, subs) = photon_ring::channel::<u64>(64);
//! let mut sub = subs.subscribe();
//! pub_.publish(42);
//! assert_eq!(sub.try_recv(), Ok(42));
//!
//! // Named-topic bus
//! let bus = photon_ring::Photon::<u64>::new(64);
//! let mut p = bus.publisher("topic-a");
//! let mut s = bus.subscribe("topic-a");
//! p.publish(7);
//! assert_eq!(s.try_recv(), Ok(7));
//! ```
extern crate alloc;
pub
pub
pub use DependencyBarrier;
pub use Photon;
pub use ;
pub use Pod;
pub use Padded;
/// Derive macro for the [`Pod`] trait. Requires the `derive` feature.
///
/// ```ignore
/// #[derive(photon_ring::DerivePod, Clone, Copy)]
/// #[repr(C)]
/// struct Quote { price: f64, volume: u32 }
/// ```
pub use Pod as DerivePod;
/// Derive macro that generates a Pod-compatible wire struct from a domain struct.
///
/// Given a struct with `bool`, `Option<numeric>`, `usize`/`isize`, and
/// `#[repr(u8)]` enum fields, generates `{Name}Wire` plus `From` conversions.
/// Structs without enum fields get safe `From` impls in both directions;
/// structs with enum fields get `From<Domain> for Wire` (safe) and
/// `Wire::into_domain()` (unsafe). Requires the `derive` feature.
///
/// ```ignore
/// #[derive(photon_ring::DeriveMessage)]
/// struct Order { price: f64, side: Side, filled: bool, tag: Option<u32> }
/// // Generates: OrderWire, From<Order> for OrderWire, From<OrderWire> for Order
/// ```
pub use Message as DeriveMessage;
pub use Shutdown;
pub use TypedBus;
pub use WaitStrategy;