pub struct Store { /* private fields */ }Implementations§
Source§impl Store
impl Store
pub fn open(path: &Path) -> Result<Store>
Sourcepub fn insert_template(&self, t: &TemplateRow) -> Result<()>
pub fn insert_template(&self, t: &TemplateRow) -> Result<()>
Fails when the name is taken.
Sourcepub fn update_template_settings(&self, t: &TemplateRow) -> Result<()>
pub fn update_template_settings(&self, t: &TemplateRow) -> Result<()>
Writes every column except the generation pointers (current_gen, next_gen).
Sourcepub fn ensure_mask_salt(&self, name: &str, salt: &str) -> Result<String>
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.
Sourcepub fn delete_template(&self, name: &str) -> Result<()>
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.
pub fn get_template(&self, name: &str) -> Result<Option<TemplateRow>>
pub fn list_templates(&self) -> Result<Vec<TemplateRow>>
Sourcepub fn alloc_gen(&self, name: &str) -> Result<u32>
pub fn alloc_gen(&self, name: &str) -> Result<u32>
Returns the template’s next generation number and moves next_gen past it.
pub fn insert_generation(&self, g: &GenerationRow) -> Result<()>
pub fn get_generation( &self, name: &str, gen: u32, ) -> Result<Option<GenerationRow>>
Sourcepub fn list_generations(&self, name: &str) -> Result<Vec<GenerationRow>>
pub fn list_generations(&self, name: &str) -> Result<Vec<GenerationRow>>
Oldest first.
Sourcepub fn current(
&self,
name: &str,
) -> Result<Option<(TemplateRow, GenerationRow)>>
pub fn current( &self, name: &str, ) -> Result<Option<(TemplateRow, GenerationRow)>>
The template and its current generation; None while it has none.
Sourcepub fn set_current(
&self,
name: &str,
gen: u32,
expected: Option<u32>,
) -> Result<bool>
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.
pub fn delete_generation(&self, name: &str, gen: u32) -> Result<()>
pub fn insert_clone(&self, c: &CloneRow) -> Result<()>
Sourcepub fn update_clone(&self, c: &CloneRow) -> Result<()>
pub fn update_clone(&self, c: &CloneRow) -> Result<()>
CloneNotFound when the row is gone (for example destroyed meanwhile).
Sourcepub fn set_clone_status(&self, id: &str, status: CloneStatus) -> Result<bool>
pub fn set_clone_status(&self, id: &str, status: CloneStatus) -> Result<bool>
Changes only the status column; false when no row has this id.
Sourcepub fn get_clone(&self, id_or_name: &str) -> Result<Option<CloneRow>>
pub fn get_clone(&self, id_or_name: &str) -> Result<Option<CloneRow>>
Matches id first, then name.
pub fn list_clones(&self) -> Result<Vec<CloneRow>>
pub fn delete_clone(&self, id: &str) -> Result<()>
Sourcepub fn add_env_record(&self, clone_id: &str, rec: &PendingRestore) -> Result<()>
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.
Sourcepub fn env_records(&self, clone_id: &str) -> Result<Vec<PendingRestore>>
pub fn env_records(&self, clone_id: &str) -> Result<Vec<PendingRestore>>
The clone’s .env records as restores (id is 0).
pub fn delete_env_records(&self, clone_id: &str) -> Result<()>
pub fn add_pending_restore(&self, rec: &PendingRestore) -> Result<()>
pub fn list_pending_restores(&self) -> Result<Vec<PendingRestore>>
pub fn delete_pending_restore(&self, id: i64) -> Result<()>
pub fn get_reservation(&self, name: &str) -> Result<Option<ReservationRow>>
pub fn upsert_reservation(&self, r: &ReservationRow) -> Result<()>
pub fn delete_reservation(&self, name: &str) -> Result<()>
Sourcepub fn add_event(
&self,
kind: &str,
clone: Option<&str>,
template: Option<&str>,
detail: &Value,
) -> Result<EventRow>
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).
Sourcepub fn list_events(&self, f: &EventFilter) -> Result<Vec<EventRow>>
pub fn list_events(&self, f: &EventFilter) -> Result<Vec<EventRow>>
The events matching f, oldest first; with a limit, the newest limit of them.
Sourcepub fn list_events_after(
&self,
after: i64,
f: &EventFilter,
) -> Result<Vec<EventRow>>
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.
Sourcepub fn prune_events(&self, before_ts: i64, max_rows: u32) -> Result<usize>
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.
Sourcepub fn reserved_ports(&self) -> Result<HashSet<u16>>
pub fn reserved_ports(&self) -> Result<HashSet<u16>>
Every reserved port, whether or not a clone of that name runs.
Sourcepub fn drop_stale_reservations(&self, before: i64) -> Result<Vec<String>>
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.
Sourcepub fn leased_ports(&self) -> Result<HashSet<u16>>
pub fn leased_ports(&self) -> Result<HashSet<u16>>
The clone row is the port lease.