Skip to main content

Store

Struct Store 

Source
pub struct Store { /* private fields */ }
Expand description

The owner-only store under the state root.

Implementations§

Source§

impl Store

Source

pub fn new(state_root: &Utf8Path) -> Self

The store under one state root.

Source

pub fn root(&self) -> &Utf8Path

The store’s own root, for a diagnostic that names it.

Source

pub fn checked(fingerprint: &str) -> Result<&str, AppError>

Refuse an id that is not a fingerprint.

Every public entry takes the id as a string, and the strings reach Path::join, which appends whatever it is given. An id carrying a path component would name a directory outside the store, and a terminal result removes the directory its plan names. So the shape is checked once, at the boundary: exactly a lowercase hex sha256.

§Errors

AppError::Refused naming the id.

Source

pub fn directory(&self, fingerprint: &str) -> PlanDirectory

Where one fingerprint’s executable plan lives.

The caller has already run Store::checked on the id: every public entry does, and this is reachable only through one of them.

Source

pub fn results(&self, fingerprint: &str) -> Utf8PathBuf

Where one fingerprint’s terminal results live.

Source

pub fn lock_path(&self) -> Utf8PathBuf

Where the store keeps the lock that orders a whole-store walk.

Only the prune takes it, and only for as long as the walk. A per-plan write takes Store::plan_lock_path instead, because two planners for different fingerprints touch nothing in common and serializing them would make one landing wait on another’s target.

Source

pub fn plan_lock_path(&self, fingerprint: &str) -> Result<Utf8PathBuf, AppError>

Where one fingerprint’s own lock lives.

Two planners that computed the same plan race to publish it, and this is what makes the second reuse the first rather than meet a half-written directory.

§Errors

AppError::Refused for an id that is not a fingerprint.

Source

pub fn create(&self) -> Result<(), AppError>

Create the store, owner-only.

A plan carries bytes out of a target, and some of those are not the world’s business. The directory mode says so on the filesystem rather than only in a document.

§Errors

Any I/O error creating the directories or setting their mode.

Source

pub fn holds(&self, fingerprint: &str) -> bool

Whether an executable plan exists for this fingerprint.

Source

pub fn put( &self, plan: &Plan, blobs: &BTreeMap<Sha256, Vec<u8>>, ) -> Result<PlanDirectory, AppError>

Write one plan and every byte it will land.

§Errors

Any I/O error creating the directory or writing the plan.

Source

pub fn get(&self, fingerprint: &str) -> Result<Plan, AppError>

Read one stored plan.

§Errors

AppError::Refused when no executable plan carries that fingerprint, and I/O errors when it cannot be read.

Source

pub fn blob( &self, fingerprint: &str, digest: &Sha256, ) -> Result<Vec<u8>, AppError>

One byte string the plan will write.

§Errors

AppError::Refused when the plan’s blob store does not carry it.

Source

pub fn record(&self, plan: &Plan, result: &Result) -> Result<(), AppError>

Record one attempt’s outcome.

A terminal disposition moves the redacted plan out with its result and frees the fingerprint. Anything else leaves the executable plan where it is, because the same plan can still be applied.

§Errors

Any I/O error writing the result or moving the plan.

Source

pub fn latest_result(&self, fingerprint: &str) -> Option<Result>

The latest result for one fingerprint, where any exists.

Source

pub fn prune( &self, now: Timestamp, keep: Option<&str>, ) -> Result<Vec<Utf8PathBuf>, AppError>

Remove what the lifecycle says is over.

Never removes the fingerprint the caller named, and never removes a directory that still holds a journal: a run that did not finish keeps everything recovery needs, whatever the calendar says.

§Errors

Any I/O error reading the store.

Trait Implementations§

Source§

impl Clone for Store

Source§

fn clone(&self) -> Store

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 Store

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Store

§

impl RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

§

impl UnwindSafe for Store

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

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
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