pub struct AuditLog { /* private fields */ }Expand description
Audit log: maintains the Merkle tree of event hashes and generates C2SP-compatible checkpoints and proofs using Google’s tlog algorithm.
Implementations§
Source§impl AuditLog
impl AuditLog
pub fn new(pool: SqlitePool, origin: impl Into<String>) -> Self
Sourcepub async fn append_leaf(
&self,
log_index: u64,
leaf_hash_hex: &str,
) -> Result<(), AuditError>
pub async fn append_leaf( &self, log_index: u64, leaf_hash_hex: &str, ) -> Result<(), AuditError>
Appends the leaf hash to the Merkle tree within an internal transaction.
log_index is 0-based. leaf_hash_hex is the 64-char hex event_hash.
Sourcepub async fn append_leaf_in_tx(
&self,
tx: &mut Transaction<'_, Sqlite>,
log_index: u64,
leaf_hash_hex: &str,
) -> Result<(), AuditError>
pub async fn append_leaf_in_tx( &self, tx: &mut Transaction<'_, Sqlite>, log_index: u64, leaf_hash_hex: &str, ) -> Result<(), AuditError>
Appends the leaf hash to the Merkle tree within a caller-provided transaction.
Sourcepub async fn make_checkpoint(
&self,
tree_size: u64,
) -> Result<AuditCheckpoint, AuditError>
pub async fn make_checkpoint( &self, tree_size: u64, ) -> Result<AuditCheckpoint, AuditError>
Generates and persists a checkpoint within an internal transaction.
tree_size = log_index + 1 (number of events committed so far).
Sourcepub async fn make_checkpoint_in_tx(
&self,
tx: &mut Transaction<'_, Sqlite>,
tree_size: u64,
) -> Result<AuditCheckpoint, AuditError>
pub async fn make_checkpoint_in_tx( &self, tx: &mut Transaction<'_, Sqlite>, tree_size: u64, ) -> Result<AuditCheckpoint, AuditError>
Generates and persists a checkpoint within a caller-provided transaction.
Sourcepub async fn latest_checkpoint(&self) -> Result<AuditCheckpoint, AuditError>
pub async fn latest_checkpoint(&self) -> Result<AuditCheckpoint, AuditError>
Returns the latest checkpoint, if any.
Sourcepub async fn inclusion_proof(
&self,
log_index: u64,
tree_size: u64,
) -> Result<Vec<String>, AuditError>
pub async fn inclusion_proof( &self, log_index: u64, tree_size: u64, ) -> Result<Vec<String>, AuditError>
Generates an inclusion proof showing that the event at log_index
is contained in the tree of size tree_size.
Returns proof hashes as hex strings (RFC 6962 Merkle audit path).
Sourcepub async fn consistency_proof(
&self,
old_size: u64,
new_size: u64,
) -> Result<Vec<String>, AuditError>
pub async fn consistency_proof( &self, old_size: u64, new_size: u64, ) -> Result<Vec<String>, AuditError>
Generates a consistency proof showing that the tree of size new_size
is an append-only extension of the tree of size old_size.
Returns proof hashes as hex strings (RFC 6962 consistency proof).
Sourcepub async fn tree_size(&self) -> Result<u64, AuditError>
pub async fn tree_size(&self) -> Result<u64, AuditError>
Returns the current tree size (number of leaves stored).
Sourcepub async fn ensure_checkpoint(
&self,
event_count: u64,
) -> Result<(), AuditError>
pub async fn ensure_checkpoint( &self, event_count: u64, ) -> Result<(), AuditError>
Ensure the checkpoint is up-to-date with the given event count. If the latest checkpoint is stale, generates a new one. Called lazily on read operations that need a current checkpoint.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AuditLog
impl !RefUnwindSafe for AuditLog
impl Send for AuditLog
impl Sync for AuditLog
impl Unpin for AuditLog
impl UnsafeUnpin for AuditLog
impl !UnwindSafe for AuditLog
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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