pub struct Store { /* private fields */ }Expand description
The atom database, plus the lock that makes it one writer.
Implementations§
Source§impl Store
impl Store
Sourcepub fn open(root: &Path) -> Result<Self>
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.
Sourcepub fn for_each(
&self,
workspace: Option<&str>,
visit: impl FnMut(&Record),
) -> Result<()>
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.
Sourcepub fn upsert(&self, atom: &Record) -> Result<()>
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.
Sourcepub fn upsert_many(&self, atoms: &[Record]) -> Result<()>
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.
Sourcepub fn live(&self, workspace: &str) -> Result<Arc<Vec<Record>>>
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.
Sourcepub fn searchable(&self, workspace: &str) -> Result<SearchSet>
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.
Sourcepub fn as_of(&self, workspace: &str, at: &str) -> Result<Vec<Record>>
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.
Sourcepub fn current(&self, workspace: &str, set: Option<&str>) -> Result<Vec<Record>>
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.
Sourcepub fn workspaces(&self) -> Result<Vec<(String, usize)>>
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.