Skip to main content

Datastore

Struct Datastore 

Source
pub struct Datastore { /* private fields */ }

Implementations§

Source§

impl Datastore

Source

pub fn builder() -> DatastoreBuilder

Source

pub fn from_env() -> Result<Self>

From env + ~/.config/starfield/datastore.toml + defaults.

Source

pub fn cache_root(&self) -> &Path

Source

pub fn max_bytes(&self) -> Option<u64>

The configured cache budget, if any. Enforced only by gc.

Source

pub fn get(&self, artifact: &Artifact) -> Result<PathBuf>

Resolve to a local path, fetching through the chain if needed.

Source

pub fn get_with_outcome( &self, artifact: &Artifact, ) -> Result<(PathBuf, ResolveOutcome)>

As get, reporting which layer served it.

Source

pub fn get_bytes(&self, artifact: &Artifact) -> Result<Vec<u8>>

Read fully into memory. For small artifacts only.

Source

pub fn import(&self, artifact: &Artifact, path: &Path) -> Result<PathBuf>

Seed the cache from a file already on disk, validating it exactly as a download would be. The file is copied, not moved.

Source

pub fn peek(&self, key: &ArtifactKey) -> Option<PathBuf>

Local path if already cached; never fetches and never rehashes.

Source

pub fn contains(&self, key: &ArtifactKey) -> bool

Source

pub fn entry(&self, key: &ArtifactKey) -> Option<IndexEntry>

The index sidecar for key, if cached.

Source

pub fn remove(&self, key: &ArtifactKey) -> Result<()>

Source

pub fn keys(&self) -> Result<Vec<ArtifactKey>>

Source

pub fn total_bytes(&self) -> Result<u64>

Bytes on disk across all blobs, orphans included; shared blobs count once.

Source

pub fn verify(&self) -> Result<Vec<VerifyFailure>>

Rehash every blob; report keys whose blob is missing, hashes to a different digest, or has a size that disagrees with the sidecar. These are the index-integrity checks get makes on a hit; the artifact’s own ContentCheck needs an Artifact and is not run here.

Source

pub fn gc(&self, max_bytes: u64) -> Result<Vec<ArtifactKey>>

Reclaim space: first orphan blobs, then the least-recently-fetched keys until the store is within max_bytes. Explicit only: nothing is evicted during get, so a path handed out earlier stays valid until the caller chooses to run this. tmp/ is left alone: a temp file’s age says nothing about whether its transfer is still running, so leftovers from a crash are for the operator to remove.

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

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = !

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

impl<T> WithSubscriber for T

Source§

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

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

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