Skip to main content

Store

Struct Store 

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

The atom database, plus the lock that makes it one writer.

Implementations§

Source§

impl Store

Source

pub fn open(root: &Path) -> Result<Self>

Open the database under root, taking the single-writer lock.

§Errors

Fails when the home cannot be created, when another process already holds the lock, or when LMDB refuses the directory.

Source

pub fn scan(&self, workspace: Option<&str>) -> Result<Vec<Record>>

Every record in one workspace, or in all of them.

§Errors

Fails when the read transaction does.

Source

pub fn for_each( &self, workspace: Option<&str>, visit: impl FnMut(&Record), ) -> Result<()>

Visit each record without collecting them. Status counts 30k expired atoms this way instead of holding every JSON value at once.

§Errors

Fails when the read transaction does.

Source

pub fn get(&self, workspace: &str, id: &str) -> Result<Option<Record>>

One record by id, whatever its state.

§Errors

Fails when the read transaction does.

Source

pub fn upsert(&self, atom: &Record) -> Result<()>

Write one record, replacing whatever shared its key.

§Errors

Fails when the record has no workspace or id, or when the write does.

Source

pub fn upsert_many(&self, atoms: &[Record]) -> Result<()>

Write several records in one transaction, so a link rewrite lands whole.

§Errors

Fails when a record has no workspace or id, or when the write does.

Source

pub fn live(&self, workspace: &str) -> Result<Arc<Vec<Record>>>

The live and due records in one workspace, parsed once per write and shared; readers take this over Store::current.

§Errors

Fails when the scan does.

Source

pub fn searchable(&self, workspace: &str) -> Result<SearchSet>

One workspace’s live atoms and the index over them, as a matched pair; cards are scored against the same corpus.

§Errors

Fails when the scan does.

Source

pub fn as_of(&self, workspace: &str, at: &str) -> Result<Vec<Record>>

The atoms that were live at at, from a store scan since the snapshot drops closed windows.

§Errors

Fails when the scan does, or when at is not a timestamp.

Source

pub fn current(&self, workspace: &str, set: Option<&str>) -> Result<Vec<Record>>

The live and due records in one workspace, as a copy the caller owns.

§Errors

Fails when the scan does.

Source

pub fn workspaces(&self) -> Result<Vec<(String, usize)>>

Distinct workspace names with their live counts. global is always in.

§Errors

Fails when the scan does.

Source

pub fn delete( &self, workspace: &str, id: &str, why: Option<&str>, ) -> Result<Record>

Tombstone one live record, optionally naming the deed that withdrew it.

The whole record is carried onto the tombstone, so why lands beside the text it retracts and a bitemporal read gets both at once.

§Errors

AtomError when the id is not in the current set, else the write’s.

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