pub struct AuditTrail { /* private fields */ }Expand description
Audit trail manager
Implementations§
Source§impl AuditTrail
impl AuditTrail
Sourcepub fn new(config: AuditTrailConfig) -> Self
pub fn new(config: AuditTrailConfig) -> Self
Create a new audit trail with the given configuration.
Sourcepub fn log_event(
&mut self,
event_type: AuditEventType,
cid: &str,
actor: &str,
details: &str,
bytes: u64,
success: bool,
) -> u64
pub fn log_event( &mut self, event_type: AuditEventType, cid: &str, actor: &str, details: &str, bytes: u64, success: bool, ) -> u64
Record an event and return its sequence number.
If config.log_reads is false, BlockGet events are silently
dropped and the returned sequence number is 0.
Sourcepub fn query(&self, filter: &AuditFilter) -> Vec<&AuditEntry>
pub fn query(&self, filter: &AuditFilter) -> Vec<&AuditEntry>
Return entries matching every predicate in filter.
Sourcepub fn get_entry(&self, sequence: u64) -> Option<&AuditEntry>
pub fn get_entry(&self, sequence: u64) -> Option<&AuditEntry>
Look up an entry by its sequence number.
Sourcepub fn verify_integrity(&self) -> Result<(), Vec<u64>>
pub fn verify_integrity(&self) -> Result<(), Vec<u64>>
Verify the integrity checksum of every entry.
Returns Ok(()) when all entries pass, or Err(bad_seqs) with
the sequence numbers that failed.
Sourcepub fn prune_before(&mut self, timestamp: u64) -> usize
pub fn prune_before(&mut self, timestamp: u64) -> usize
Remove all entries whose timestamp is strictly before timestamp.
Returns the number of entries removed.
Sourcepub fn prune_to_capacity(&mut self) -> usize
pub fn prune_to_capacity(&mut self) -> usize
Trim the trail to config.max_entries, removing the oldest entries
first. Returns the number of entries removed.
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
Number of entries currently held.
Sourcepub fn last_entry(&self) -> Option<&AuditEntry>
pub fn last_entry(&self) -> Option<&AuditEntry>
The most recently appended entry, if any.
Sourcepub fn stats(&self) -> &AuditTrailStats
pub fn stats(&self) -> &AuditTrailStats
Current aggregate statistics.
Sourcepub fn events_for_cid(&self, cid: &str) -> Vec<&AuditEntry>
pub fn events_for_cid(&self, cid: &str) -> Vec<&AuditEntry>
All events that reference a particular CID.
Sourcepub fn recent_failures(&self, count: usize) -> Vec<&AuditEntry>
pub fn recent_failures(&self, count: usize) -> Vec<&AuditEntry>
The most recent count entries where success == false, newest first.
Auto Trait Implementations§
impl Freeze for AuditTrail
impl RefUnwindSafe for AuditTrail
impl Send for AuditTrail
impl Sync for AuditTrail
impl Unpin for AuditTrail
impl UnsafeUnpin for AuditTrail
impl UnwindSafe for AuditTrail
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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>
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