Skip to main content

Store

Struct Store 

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

A backend opened against a declaration of needs.

Implementations§

Source§

impl Store

Source

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

Open config, refusing it if it cannot give every need in needs.

Source

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

Read the whole value at key. A key with no value is Error::NotFound, distinct from a backend failure.

Source

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

Replace the value at key in one step.

Source

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

Delete key. Deleting a key that does not exist is not an error.

Source

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

Size and modification time of the value at key. A key with no value (or one that names a directory) is Error::NotFound. Needs Need::Stat.

Source

pub async fn list( &self, prefix: &str, after: Option<&str>, limit: NonZeroUsize, ) -> Result<Page>

List up to limit keys that start with prefix, in ascending key order, strictly after after if given (pass the previous page’s Page::next). Needs Need::List and Need::Stat.

prefix is a plain string prefix of the key, not a directory: "img/a" matches "img/a.png" and "img/ab/c". OpenDAL only lists directories, so this lists every key under the prefix’s directory part ("img/") and filters: emulated, and the cost is a scan of that whole directory tree. Memory is bounded by limit, not by the tree; time is not, so a large tree is rescanned for every page. Keys that vanish while a page is being built are left out.

Source

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

Write bytes at key only if nothing is there yet; otherwise Error::AlreadyExists and nothing changes. Needs Need::Write and Need::CreateIfAbsent.

Native, never emulated: a backend that cannot do this exclusively is refused at open (see Need::CreateIfAbsent). On fs that means atomic_write_dir must be unset, because OpenDAL’s atomic path checks for the key and then renames, which two creators can both pass. Without it the file is created exclusively but written in place, so a reader may see a partly written value of a large create. This write is not counted by the fault-injecting fake.

Source

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

Store record under key as a versioned envelope, replacing atomically.

Source

pub async fn get_record<R: Record>(&self, key: &str) -> Result<Option<R>>

Read the record at key: None if absent. An older schema goes through Record::upgrade; a newer one, or another kind, is refused.

Source

pub async fn begin_replace(&self, key: &str) -> Result<Replace>

Start a replacement that can be written in pieces (the fault-injecting fake applies here too). Dropping it without commit leaves the old value in place, but on fs the unfinished temporary file stays in atomic_write_dir (OpenDAL has no cleanup on drop); sweep that directory at startup. Durability across power loss is not claimed: OpenDAL syncs the file, not the parent directory, before the rename.

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 !Freeze for Store

§

impl !RefUnwindSafe for Store

§

impl !UnwindSafe for Store

§

impl Forget for Store

§

impl Move for Store

§

impl Send for Store
where Arc<dyn ServiceDyn>: Send, Arc<dyn HttpTransportDyn>: Send, Arc<dyn Execute>: Send, Arc<Vec<Arc<dyn Layer>>>: Send, RawVecInner: Send, Atomic<usize>: Send,

§

impl Sync for Store
where Arc<dyn ServiceDyn>: Sync, Arc<dyn HttpTransportDyn>: Sync, Arc<dyn Execute>: Sync, Arc<Vec<Arc<dyn Layer>>>: Sync, RawVecInner: Sync, Atomic<usize>: Sync,

§

impl Unpin for Store
where Arc<dyn ServiceDyn>: Unpin, Arc<dyn HttpTransportDyn>: Unpin, Arc<dyn Execute>: Unpin, Arc<Vec<Arc<dyn Layer>>>: Unpin, *const u8 is !null: Unpin, Align8<usize>: Unpin,

§

impl UnsafeUnpin for Store
where *const ArcInner<dyn ServiceDyn> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn ServiceDyn>>: UnsafeUnpin, *const ArcInner<dyn HttpTransportDyn> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn HttpTransportDyn>>: UnsafeUnpin, *const ArcInner<dyn Execute> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Execute>>: UnsafeUnpin, *const ArcInner<Vec<Arc<dyn Layer>>> is !null: UnsafeUnpin, PhantomData<ArcInner<Vec<Arc<dyn Layer>>>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<Need>: UnsafeUnpin, Align8<usize>: 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.