pub struct AuditState {
pub sink: RwLock<Option<Arc<AuditSink>>>,
pub sequence: AtomicU64,
}Expand description
V-4 audit chain state. Owns the same (sink, sequence) pair the
pre-#1192 src/audit.rs module-level statics owned; the public
crate::audit::* functions delegate here.
The chain invariants this struct preserves byte-for-byte:
sinkis wrapped inRwLock<Option<Arc<AuditSink>>>so theinitpath can swap the sink atomically andemitcan clone theArcwithout holding the lock for the file write.sequenceis anAtomicU64so concurrent emit threads agree on a monotonic counter; it is seeded from the trailing record’s sequence oninit(F2 fix — sequence survives daemon restart).- The
AuditSink::innermutex serialises the hash-chain head update + line write, so the chain is consistent across producer threads.
Fields§
§sink: RwLock<Option<Arc<AuditSink>>>Process-wide audit sink. None when audit is disabled. Wrapped
in RwLock (rather than OnceLock) so tests can swap in an
in-memory sink between cases without leaking state across runs.
sequence: AtomicU64Per-process monotonic sequence counter. Starts at 0; first emit
produces sequence 1. init reseeds from the trailing record’s
sequence so audit verify doesn’t trip on a restart-induced
reset (F2 round-2 fix).
Trait Implementations§
Source§impl Debug for AuditState
impl Debug for AuditState
Source§impl Default for AuditState
impl Default for AuditState
Source§fn default() -> AuditState
fn default() -> AuditState
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for AuditState
impl RefUnwindSafe for AuditState
impl Send for AuditState
impl Sync for AuditState
impl Unpin for AuditState
impl UnsafeUnpin for AuditState
impl UnwindSafe for AuditState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more