pub struct MemoryAuditSink { /* private fields */ }Expand description
Test-support sink — accumulates events in insertion order behind a
Mutex.
Test code calls MemoryAuditSink::events to assert ordering and
contents. The Arc<Mutex<Vec<...>>> shape is deliberate:
AuditSink::record_failure takes &self, so interior mutability
is required; Mutex (rather than RwLock) is right because every
access is a mutation.
Uses std::sync::Mutex rather than tokio::sync::Mutex so the
adapter compiles unconditionally — no tokio runtime required when
downstream consumers enable just test-support without oauth /
well-known-fetch. This is safe because no .await happens while
the lock is held; the future stays Send.
Implementations§
Source§impl MemoryAuditSink
impl MemoryAuditSink
pub fn new() -> MemoryAuditSink
Sourcepub fn events(&self) -> Vec<AuditEvent>
pub fn events(&self) -> Vec<AuditEvent>
Snapshot the recorded events. Returns a clone so the caller
doesn’t hold the lock during assertion logic. AuditEvent is
shallow-cloneable; copying the whole vec is cheap for test
volumes.
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl AuditSink for MemoryAuditSink
impl AuditSink for MemoryAuditSink
fn record_failure<'life0, 'async_trait>(
&'life0 self,
event: AuditEvent,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
MemoryAuditSink: 'async_trait,
Source§impl Clone for MemoryAuditSink
impl Clone for MemoryAuditSink
Source§fn clone(&self) -> MemoryAuditSink
fn clone(&self) -> MemoryAuditSink
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more