pub enum RetrievalStore {
Memory(Mutex<HashMap<(String, String), MemoryEntry>>),
Filesystem {
root: PathBuf,
},
}Expand description
A content-addressed, namespaced store for reversible originals. Backend-dispatching enum rather than a trait object: only two live variants exist in this pass, so a trait would add indirection without buying any real polymorphism.
Variants§
Implementations§
Source§impl RetrievalStore
impl RetrievalStore
pub fn memory() -> Self
pub fn filesystem(root: impl Into<PathBuf>) -> Self
Sourcepub fn default_filesystem() -> Self
pub fn default_filesystem() -> Self
The default persistent store used when nothing overrides it: a filesystem backend
rooted at default_store_path.
Sourcepub fn open(
backend: &str,
hash_algorithm: &str,
store_path_override: Option<PathBuf>,
) -> Result<Self, TokenFoldError>
pub fn open( backend: &str, hash_algorithm: &str, store_path_override: Option<PathBuf>, ) -> Result<Self, TokenFoldError>
Builds a store from tokenfold.toml’s [retrieval] schema values. hash_algorithm and
backend are validated here so that selecting an unimplemented option (blake3,
sqlite) fails clearly instead of silently behaving like sha256/filesystem.
Sourcepub fn store(
&self,
bytes: &[u8],
namespace: &str,
ttl_seconds: Option<u64>,
) -> Result<RetrievalMarker, TokenFoldError>
pub fn store( &self, bytes: &[u8], namespace: &str, ttl_seconds: Option<u64>, ) -> Result<RetrievalMarker, TokenFoldError>
Persists bytes under their SHA-256 hex hash, namespaced by namespace. Refuses to
store (and never partially stores) anything redaction::contains_secret flags — this
check runs unconditionally inside store, so no caller anywhere (pipeline, CLI, tests)
can reach a code path that stores secret-shaped bytes.
Sourcepub fn retrieve(&self, hash: &str, namespace: &str) -> RetrievalOutcome
pub fn retrieve(&self, hash: &str, namespace: &str) -> RetrievalOutcome
Looks up hash in namespace. Never returns a partial result: exactly one of
Found/Missing/Expired.
Sourcepub fn gc(
&self,
max_store_bytes: Option<u64>,
) -> Result<GcOutcome, TokenFoldError>
pub fn gc( &self, max_store_bytes: Option<u64>, ) -> Result<GcOutcome, TokenFoldError>
Deletes entries whose ttl_seconds has elapsed (entries stored with ttl_seconds: None never expire), then — if max_store_bytes is given and total remaining stored
bytes still exceed it — evicts the oldest-stored_at entries first until under the cap.