Skip to main content

SqliteAuditStore

Struct SqliteAuditStore 

Source
pub struct SqliteAuditStore { /* private fields */ }
Available on crate feature audit only.
Expand description

An AuditStore in SQLite tables a2a_audit_records, a2a_audit_checkpoints, a2a_audit_holds and a2a_audit_subject_keys, created if absent.

It can share a database (and a pool) with SqliteTaskStore; it touches only its own tables. Each record is stored as the exact JSON it was sealed with, so it reads back byte-for-byte equal and its hash still verifies.

Implementations§

Source§

impl SqliteAuditStore

Source

pub async fn new(url: &str) -> Result<SqliteAuditStore, Error>

Opens (or creates) a database at url and its audit tables.

§Errors

Returns an error if the database cannot be opened or the tables created.

Source

pub async fn from_pool(pool: Pool<Sqlite>) -> Result<SqliteAuditStore, Error>

Uses an existing pool, creating the audit tables if absent.

§Errors

Returns an error if the tables cannot be created.

Trait Implementations§

Source§

impl AuditStore for SqliteAuditStore

Source§

fn delete_through_unless_held<'a>( &'a self, chain: &'a str, seq: u64, ) -> Pin<Box<dyn Future<Output = Result<Option<u64>, A2aError>> + Send + 'a>>

One transaction whose first statement is a write: that takes SQLite’s write lock, which a hold’s insert needs too, so the hold is read and the records deleted with none placed in between. The hold is tested inside each DELETE, so a held chain loses nothing.

Source§

fn is_process_local(&self) -> bool

Whether this store keeps its state in this process alone. Read more
Source§

fn head<'a>( &'a self, chain: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<(u64, String)>, A2aError>> + Send + 'a>>

The highest seq stored in chain and that record’s hash.
Source§

fn append<'a>( &'a self, record: &'a AuditRecord, ) -> Pin<Box<dyn Future<Output = Result<Appended, A2aError>> + Send + 'a>>

Stores a sealed record, unless its (chain, seq) is already taken.
Source§

fn read<'a>( &'a self, chain: &'a str, after: u64, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<AuditRecord>, A2aError>> + Send + 'a>>

Up to limit records of chain with seq above after, in order.
Source§

fn chains( &self, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, A2aError>> + Send + '_>>

Every chain that holds a record or a checkpoint.
Source§

fn put_checkpoint<'a>( &'a self, checkpoint: &'a Checkpoint, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>

Stores a checkpoint, replacing one of the same chain, seq and kind.
Source§

fn checkpoints<'a>( &'a self, chain: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Checkpoint>, A2aError>> + Send + 'a>>

Every checkpoint of chain, in seq order.
Source§

fn last_before<'a>( &'a self, chain: &'a str, cutoff_ms: i64, ) -> Pin<Box<dyn Future<Output = Result<Option<(u64, String)>, A2aError>> + Send + 'a>>

The last record of chain sealed before cutoff_ms (Unix milliseconds), as (seq, hash).
Source§

fn delete_through<'a>( &'a self, chain: &'a str, seq: u64, ) -> Pin<Box<dyn Future<Output = Result<u64, A2aError>> + Send + 'a>>

Deletes the records of chain up to and including seq, and the checkpoints below seq (an anchor at seq itself is kept). Returns how many records went.
Source§

fn place_hold<'a>( &'a self, hold: &'a LegalHold, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>

Places a hold on chain, replacing any reason already given.
Source§

fn release_hold<'a>( &'a self, chain: &'a str, ) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>

Lifts the hold on chain; returns whether there was one.
Source§

fn holds( &self, ) -> Pin<Box<dyn Future<Output = Result<Vec<LegalHold>, A2aError>> + Send + '_>>

Every hold in place.
Source§

fn supports_subject_keys(&self) -> bool

Whether this store keeps subject keys. AuditLog::with_privacy refuses a store that answers false.
Source§

fn subject_key<'a>( &'a self, chain: &'a str, lookup: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<SubjectKey>, A2aError>> + Send + 'a>>

The key of chain whose lookup is lookup. Read more
Source§

fn subject_key_by_sid<'a>( &'a self, chain: &'a str, sid: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<SubjectKey>, A2aError>> + Send + 'a>>

The key of chain whose handle is sid. Read more
Source§

fn subject_keys<'a>( &'a self, chain: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Vec<SubjectKey>, A2aError>> + Send + 'a>>

Every subject key of chain, for dropping those no record names. Read more
Source§

fn put_subject_key<'a>( &'a self, chain: &'a str, key: &'a SubjectKey, ) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>

Stores key for chain unless a key with its lookup is there; false when one was, and nothing was stored. Atomic: of two writers racing on one lookup, exactly one stores. Read more
Source§

fn delete_subject_key<'a>( &'a self, chain: &'a str, lookup: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, A2aError>> + Send + 'a>>

Deletes the key of chain whose lookup is lookup, returning its sid, or None when there was none. Must not leave a copy: what it deletes is what erasure destroys. Read more
Source§

fn append_next_naming<'a>( &'a self, chain: &'a str, sids: &'a [String], seal: &'a (dyn Fn(Option<(u64, String)>, Option<i64>) -> Pin<Box<dyn Future<Output = Result<AuditRecord, A2aError>> + Send + 'a>> + Send + Sync), ) -> Pin<Box<dyn Future<Output = Result<NamedAppend, A2aError>> + Send + 'a>>

append_next for a record sealed under the keys whose handles are sids: stores it only if every one of those keys is still in the store, checked atomically with the store’s write, so that delete_subject_key_unless_named either sees this record or deleted the key before it, which this then sees. The same contract as append_next otherwise. Read more
Source§

fn delete_subject_key_unless_named<'a>( &'a self, chain: &'a str, lookup: &'a str, sid: &'a str, scanned_through: u64, ) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>

Deletes the key of chain whose lookup is lookup and handle sid, unless a record with seq above scanned_through references sid (sid_marker); true when it was deleted. For dropping keys no record names: the caller has read the chain through scanned_through, found no record naming sid, and this checks the records stored since, atomically with the deletion (see append_next_naming). Read more
Source§

fn delete_subject_keys_unless_held<'a>( &'a self, chain: &'a str, lookups: &'a [String], ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<String>>, A2aError>> + Send + 'a>>

Deletes every key of chain whose lookup is in lookups, unless a legal hold is placed on chain: None when one is, with nothing deleted; otherwise the sid of each key deleted. All or nothing, and the hold is read atomically with the deletion, as delete_through_unless_held reads it. Read more
Source§

fn append_next<'a>( &'a self, chain: &'a str, seal: &'a (dyn Fn(Option<(u64, String)>, Option<i64>) -> Pin<Box<dyn Future<Output = Result<AuditRecord, A2aError>> + Send + 'a>> + Send + Sync), ) -> Pin<Box<dyn Future<Output = Result<Option<AuditRecord>, A2aError>> + Send + 'a>>

Appends the next record of chain: reads its head, has seal build the record that follows it, and stores that. Ok(None) when another writer took the position first: nothing was stored, and the caller asks again. Read more
Source§

impl Clone for SqliteAuditStore

Source§

fn clone(&self) -> SqliteAuditStore

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SqliteAuditStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more