pub struct AuditChain { /* private fields */ }Expand description
A tamper-proof hash chain of audit events.
Each event’s prev_hash links to the SHA-256 hash of the preceding event,
forming a chain. If any event is deleted or modified, the chain breaks.
Implementations§
Source§impl AuditChain
impl AuditChain
pub fn new() -> Self
Sourcepub async fn append(&self, event: AuditEvent) -> AuditEvent
pub async fn append(&self, event: AuditEvent) -> AuditEvent
Append an event to the chain, linking it to the previous event’s hash.
Sourcepub async fn verify(&self) -> Result<(), AuditError>
pub async fn verify(&self) -> Result<(), AuditError>
Verify the integrity of the entire chain.
Returns Ok(()) if the chain is intact, or an error describing the
first integrity violation found.
Sourcepub async fn events(&self) -> Vec<AuditEvent>
pub async fn events(&self) -> Vec<AuditEvent>
Get a snapshot of all events in the chain.
Trait Implementations§
Source§impl Clone for AuditChain
impl Clone for AuditChain
Source§fn clone(&self) -> AuditChain
fn clone(&self) -> AuditChain
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AuditChain
impl !RefUnwindSafe for AuditChain
impl Send for AuditChain
impl Sync for AuditChain
impl Unpin for AuditChain
impl UnsafeUnpin for AuditChain
impl !UnwindSafe for AuditChain
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