Skip to main content

Store

Struct Store 

Source
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

Source

pub fn open(config: Config, needs: Needs) -> Result<Store>

Open config against needs, refusing a backend that cannot give them (see crate::Store::open).

Source

pub fn read(&self, key: &str) -> Result<Vec<u8>>

Read the whole value at key.

Source

pub fn replace(&self, key: &str, bytes: Vec<u8>) -> Result<()>

Replace the value at key atomically (see crate::Store::replace).

Source

pub fn delete(&self, key: &str) -> Result<()>

Delete key; deleting a key that does not exist is not an error.

Source

pub fn stat(&self, key: &str) -> Result<Entry>

Size and modification time of key (see crate::Store::stat).

Source

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

Source

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

Source

pub fn put_record<R: Record>(&self, key: &str, record: &R) -> Result<()>

Store record under key (see crate::Store::put_record).

Source

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.

Trait Implementations§

Source§

impl Debug for Store

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Store

§

impl !UnwindSafe for Store

§

impl Forget for Store

§

impl Freeze for Store
where *const ArcInner<Store> is !null: Freeze, PhantomData<ArcInner<Store>>: Freeze, *const ArcInner<Chan<Pin<Box<dyn Future<Output = ()> + Send>>, Semaphore>> is !null: Freeze, PhantomData<ArcInner<Chan<Pin<Box<dyn Future<Output = ()> + Send>>, Semaphore>>>: Freeze, *const ArcInner<Inner> is !null: Freeze, PhantomData<ArcInner<Inner>>: Freeze, *const ArcInner<Packet<'static, ()>> is !null: Freeze, PhantomData<ArcInner<Packet<'static, ()>>>: Freeze,

§

impl Move for Store

§

impl Send for Store
where Arc<Store>: Send, Arc<Chan<Pin<Box<dyn Future<Output = ()> + Send>>, Semaphore>>: Send, JoinHandle<()>: Send,

§

impl Sync for Store
where Arc<Store>: Sync, Arc<Chan<Pin<Box<dyn Future<Output = ()> + Send>>, Semaphore>>: Sync, JoinHandle<()>: Sync,

§

impl Unpin for Store
where Arc<Store>: Unpin, Arc<Chan<Pin<Box<dyn Future<Output = ()> + Send>>, Semaphore>>: Unpin, Arc<Inner, System>: Unpin, Arc<Packet<'static, ()>>: Unpin,

§

impl UnsafeUnpin for Store
where *const ArcInner<Store> is !null: UnsafeUnpin, PhantomData<ArcInner<Store>>: UnsafeUnpin, *const ArcInner<Chan<Pin<Box<dyn Future<Output = ()> + Send>>, Semaphore>> is !null: UnsafeUnpin, PhantomData<ArcInner<Chan<Pin<Box<dyn Future<Output = ()> + Send>>, Semaphore>>>: UnsafeUnpin, *const ArcInner<Inner> is !null: UnsafeUnpin, PhantomData<ArcInner<Inner>>: UnsafeUnpin, *const ArcInner<Packet<'static, ()>> is !null: UnsafeUnpin, PhantomData<ArcInner<Packet<'static, ()>>>: UnsafeUnpin,

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> MaybeSend for T
where T: Send,

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.