pub struct SeqRing<T: Copy, const N: usize> { /* private fields */ }Expand description
Overwrite ring for SPSC high-rate telemetry. Producer never waits; consumer may drop if it lags > N.
Implementations§
Source§impl<T: Copy, const N: usize> SeqRing<T, N>
impl<T: Copy, const N: usize> SeqRing<T, N>
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Create a new ring buffer.
On the normal (non-Loom) build this is a const fn, so the ring can be
placed in a static: static RING: SeqRing<u32, 64> = SeqRing::new();.
Under --cfg loom it is deliberately non-const — Loom’s atomics are
not const-constructible.
§Capacity 0 is a build failure
The N > 0 check is a const assertion, so a zero-capacity buffer
cannot be constructed at all – there is no runtime panic left to
catch, and therefore no way to write the negative case as a #[test].
This compile_fail doctest is that coverage, and pinning the error code
keeps it honest: without it the test would also pass on a typo.
let _ = ph_eventing::SeqRing::<u32, 0>::new();§Panics
Does not panic on the host path. Under Loom, where new is non-const,
N == 0 is a runtime assertion instead.
Sourcepub fn try_producer(&self) -> Option<Producer<'_, T, N>>
pub fn try_producer(&self) -> Option<Producer<'_, T, N>>
Try to create the producer handle.
Returns None if a producer is already active — never panics. On the
targets this crate exists for a panic is a reset, so fallible bring-up
is the only handle-acquisition API. (The panicking producer() was
deprecated in 0.2.0 and removed in 0.3.0.)
Sourcepub fn try_consumer(&self) -> Option<Consumer<'_, T, N>>
pub fn try_consumer(&self) -> Option<Consumer<'_, T, N>>
Try to create the consumer handle.
Returns None if a consumer is already active — never panics. On the
targets this crate exists for a panic is a reset, so fallible bring-up
is the only handle-acquisition API. (The panicking consumer() was
deprecated in 0.2.0 and removed in 0.3.0.)