auths_id/attestation/export.rs
1use crate::error::StorageError;
2use auths_verifier::core::{Attestation, VerifiedAttestation};
3use std::sync::Arc;
4
5/// Function signature for encoding an attestation into bytes.
6pub type AttestationEncoder =
7 Arc<dyn Fn(&Attestation) -> Result<Vec<u8>, StorageError> + Send + Sync>;
8
9/// Trait for destinations that can accept and store an attestation.
10pub trait AttestationSink {
11 /// Export/Save a verified attestation to the configured destination.
12 ///
13 /// Accepts a [`VerifiedAttestation`] to enforce at the type level that
14 /// signatures were checked before storage.
15 fn export(&self, attestation: &VerifiedAttestation) -> Result<(), StorageError>;
16
17 /// Update any secondary index after an attestation mutation.
18 ///
19 /// The default implementation is a no-op. Adapters backed by a searchable
20 /// index (e.g. SQLite) override this to keep their index consistent.
21 /// Callers invoke this unconditionally after every mutation — no feature
22 /// flags are needed in orchestration code.
23 fn sync_index(&self, _attestation: &Attestation) {}
24}