pub struct Store { /* private fields */ }Expand description
A crate::Store for synchronous code. Same needs, same refusals, same atomic replace.
An operation that panics is reported as Error::Panicked and the store keeps working.
Dropping a Store waits, with no timeout, for the worker thread to finish. Operations from other
threads that are still in flight run to completion first, so a drop can block as long as the
slowest of them (a hung backend call blocks it indefinitely). Drop a Store only when no
thread is mid-call, or accept that wait.
Implementations§
Source§impl Store
impl Store
Sourcepub fn open(config: Config, needs: Needs) -> Result<Store>
pub fn open(config: Config, needs: Needs) -> Result<Store>
Open config against needs, refusing a backend that cannot give them (see
crate::Store::open).
Sourcepub fn replace(&self, key: &str, bytes: Vec<u8>) -> Result<()>
pub fn replace(&self, key: &str, bytes: Vec<u8>) -> Result<()>
Replace the value at key atomically (see crate::Store::replace).
Sourcepub fn delete(&self, key: &str) -> Result<()>
pub fn delete(&self, key: &str) -> Result<()>
Delete key; deleting a key that does not exist is not an error.
Sourcepub fn stat(&self, key: &str) -> Result<Entry>
pub fn stat(&self, key: &str) -> Result<Entry>
Size and modification time of key (see crate::Store::stat).
Sourcepub fn list(
&self,
prefix: &str,
after: Option<&str>,
limit: NonZeroUsize,
) -> Result<Page>
pub fn list( &self, prefix: &str, after: Option<&str>, limit: NonZeroUsize, ) -> Result<Page>
One page of keys under prefix (see crate::Store::list, including its cost).
Sourcepub fn create_if_absent(&self, key: &str, bytes: Vec<u8>) -> Result<()>
pub fn create_if_absent(&self, key: &str, bytes: Vec<u8>) -> Result<()>
Write only if the key is absent (see crate::Store::create_if_absent).
Sourcepub fn put_record<R: Record>(&self, key: &str, record: &R) -> Result<()>
pub fn put_record<R: Record>(&self, key: &str, record: &R) -> Result<()>
Store record under key (see crate::Store::put_record).
Sourcepub fn get_record<R: Record>(&self, key: &str) -> Result<Option<R>>
pub fn get_record<R: Record>(&self, key: &str) -> Result<Option<R>>
Read the record at key, None if absent (see crate::Store::get_record). Decoding,
including a Record::upgrade, runs on the calling thread, not the worker.