Skip to main content

Store

Struct Store 

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

Implementations§

Source§

impl Store

Source

pub fn open(path: &Path) -> Result<Store>

Source

pub fn insert_template(&self, t: &TemplateRow) -> Result<()>

Fails when the name is taken.

Source

pub fn update_template_settings(&self, t: &TemplateRow) -> Result<()>

Writes every column except the generation pointers (current_gen, next_gen).

Source

pub fn ensure_mask_salt(&self, name: &str, salt: &str) -> Result<String>

Stores salt as the masking salt of name unless it already has one; returns the salt in effect, so every build of a template masks with the same key.

Source

pub fn delete_template(&self, name: &str) -> Result<()>

Removes the template and all its generation rows (not their folders). Removes the template and its generation rows together, so a failure never leaves one half. A base template takes its branch templates (base = name) with it.

Source

pub fn get_template(&self, name: &str) -> Result<Option<TemplateRow>>

Source

pub fn list_templates(&self) -> Result<Vec<TemplateRow>>

Source

pub fn alloc_gen(&self, name: &str) -> Result<u32>

Returns the template’s next generation number and moves next_gen past it.

Source

pub fn insert_generation(&self, g: &GenerationRow) -> Result<()>

Source

pub fn get_generation( &self, name: &str, gen: u32, ) -> Result<Option<GenerationRow>>

Source

pub fn list_generations(&self, name: &str) -> Result<Vec<GenerationRow>>

Oldest first.

Source

pub fn current( &self, name: &str, ) -> Result<Option<(TemplateRow, GenerationRow)>>

The template and its current generation; None while it has none.

Source

pub fn set_current( &self, name: &str, gen: u32, expected: Option<u32>, ) -> Result<bool>

Compare-and-set of the current pointer: changes it only while it still equals expected (None: always) and generation gen exists. True when it was changed.

Source

pub fn delete_generation(&self, name: &str, gen: u32) -> Result<()>

Source

pub fn insert_clone(&self, c: &CloneRow) -> Result<()>

Source

pub fn update_clone(&self, c: &CloneRow) -> Result<()>

CloneNotFound when the row is gone (for example destroyed meanwhile).

Source

pub fn set_clone_status(&self, id: &str, status: CloneStatus) -> Result<bool>

Changes only the status column; false when no row has this id.

Source

pub fn get_clone(&self, id_or_name: &str) -> Result<Option<CloneRow>>

Matches id first, then name.

Source

pub fn list_clones(&self) -> Result<Vec<CloneRow>>

Source

pub fn delete_clone(&self, id: &str) -> Result<()>

Source

pub fn add_env_record(&self, clone_id: &str, rec: &PendingRestore) -> Result<()>

Remembers a .env entry that holds the clone’s URL. A second record for the same file and variable keeps the first previous (the user’s own value) and only updates the URL.

Source

pub fn env_records(&self, clone_id: &str) -> Result<Vec<PendingRestore>>

The clone’s .env records as restores (id is 0).

Source

pub fn delete_env_records(&self, clone_id: &str) -> Result<()>

Source

pub fn add_pending_restore(&self, rec: &PendingRestore) -> Result<()>

Source

pub fn list_pending_restores(&self) -> Result<Vec<PendingRestore>>

Source

pub fn delete_pending_restore(&self, id: i64) -> Result<()>

Source

pub fn get_reservation(&self, name: &str) -> Result<Option<ReservationRow>>

Source

pub fn upsert_reservation(&self, r: &ReservationRow) -> Result<()>

Source

pub fn delete_reservation(&self, name: &str) -> Result<()>

Source

pub fn add_event( &self, kind: &str, clone: Option<&str>, template: Option<&str>, detail: &Value, ) -> Result<EventRow>

Appends one entry to the event log (the time is now).

Source

pub fn list_events(&self, f: &EventFilter) -> Result<Vec<EventRow>>

The events matching f, oldest first; with a limit, the newest limit of them.

Source

pub fn list_events_after( &self, after: i64, f: &EventFilter, ) -> Result<Vec<EventRow>>

Every event with id > after that matches f (its limit is ignored), oldest first. A follower reads the log with this, so it can neither lose nor reorder an event.

Source

pub fn prune_events(&self, before_ts: i64, max_rows: u32) -> Result<usize>

Deletes events older than before_ts and all but the newest max_rows; returns how many.

Source

pub fn reserved_ports(&self) -> Result<HashSet<u16>>

Every reserved port, whether or not a clone of that name runs.

Source

pub fn drop_stale_reservations(&self, before: i64) -> Result<Vec<String>>

Deletes reservations last used before before whose name has no clone; returns their names.

Source

pub fn leased_ports(&self) -> Result<HashSet<u16>>

The clone row is the port lease.

Auto Trait Implementations§

§

impl !Freeze for Store

§

impl !RefUnwindSafe for Store

§

impl !Sync for Store

§

impl !UnwindSafe for Store

§

impl Send for Store

§

impl Unpin for Store

§

impl UnsafeUnpin 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> 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> 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