Skip to main content

RetrievalStore

Enum RetrievalStore 

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

§

Memory(Mutex<HashMap<(String, String), MemoryEntry>>)

§

Filesystem

Fields

§root: PathBuf

Implementations§

Source§

impl RetrievalStore

Source

pub fn memory() -> Self

Source

pub fn filesystem(root: impl Into<PathBuf>) -> Self

Source

pub fn default_filesystem() -> Self

The default persistent store used when nothing overrides it: a filesystem backend rooted at default_store_path.

Source

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.

Source

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.

Source

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.

Source

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.

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.