struct LogRing<const N: usize> {
state: UnsafeCell<State<N>>,
}Expand description
Single-producer/single-consumer byte ring with overwrite-oldest policy.
Every operation runs inside one critical section. Positions are logical
usize cursors masked into the buffer (size must be a power of two), so
wrap-around is just masking and dropping the oldest bytes never moves
data.
Fields§
§state: UnsafeCell<State<N>>Implementations§
Source§impl<const N: usize> LogRing<N>
impl<const N: usize> LogRing<N>
Sourcefn push(&self, data: &[u8])
fn push(&self, data: &[u8])
Append data, overwriting the oldest bytes when there is not enough
room. Never panics, never allocates.
Sourcefn peek(&self, out: &mut [u8]) -> usize
fn peek(&self, out: &mut [u8]) -> usize
Copy up to out.len() pending bytes into out without consuming
them. Returns how many were copied.
Sourcefn commit(&self, n: usize)
fn commit(&self, n: usize)
Mark the n most recently peeked bytes as consumed. Values larger
than the pending amount consume everything.
Sourcefn drain_snapshot(&self, out: &mut [u8]) -> usize
fn drain_snapshot(&self, out: &mut [u8]) -> usize
Copy the newest bytes into out, then empty the ring. Returns how
many bytes were written (oldest data is dropped first when out is
too small).
Bytes before the floor marker are skipped: a
snapshot must contain the panic banner plus the log lines that
followed the boot-time replay, never the replayed report itself.
Sourcefn set_floor(&self)
fn set_floor(&self)
Mark the current write position as the earliest byte
drain_snapshot may capture.