pub struct KeyValueDispatch { /* private fields */ }
Implementations§
Source§impl KeyValueDispatch
impl KeyValueDispatch
pub fn new( allowed_stores: HashSet<String>, manager: Arc<dyn StoreManager>, ) -> Self
pub fn new_with_capacity( allowed_stores: HashSet<String>, manager: Arc<dyn StoreManager>, capacity: u32, ) -> Self
pub fn get_store<T: 'static>( &self, store: Resource<T>, ) -> Result<&Arc<dyn Store>>
pub fn get_cas<T: 'static>(&self, cas: Resource<T>) -> Result<&Arc<dyn Cas>>
pub fn allowed_stores(&self) -> &HashSet<String>
pub fn get_store_wasi<T: 'static>( &self, store: Resource<T>, ) -> Result<&Arc<dyn Store>, Error>
pub fn get_cas_wasi<T: 'static>( &self, cas: Resource<T>, ) -> Result<&Arc<dyn Cas>, Error>
Trait Implementations§
Source§impl Host for KeyValueDispatch
impl Host for KeyValueDispatch
Source§fn open<'life0, 'async_trait>(
&'life0 mut self,
identifier: String,
) -> Pin<Box<dyn Future<Output = Result<Resource<Bucket>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn open<'life0, 'async_trait>(
&'life0 mut self,
identifier: String,
) -> Pin<Box<dyn Future<Output = Result<Resource<Bucket>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the bucket with the specified identifier. Read more
fn convert_error(&mut self, error: Error) -> Result<Error, Error>
Source§impl Host for KeyValueDispatch
impl Host for KeyValueDispatch
Source§fn get_many<'life0, 'async_trait>(
&'life0 mut self,
bucket: Resource<Bucket>,
keys: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, Option<Vec<u8>>)>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_many<'life0, 'async_trait>(
&'life0 mut self,
bucket: Resource<Bucket>,
keys: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, Option<Vec<u8>>)>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the key-value pairs associated with the keys in the store. It returns a list of
key-value pairs. Read more
Source§fn set_many<'life0, 'async_trait>(
&'life0 mut self,
bucket: Resource<Bucket>,
key_values: Vec<(String, Vec<u8>)>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_many<'life0, 'async_trait>(
&'life0 mut self,
bucket: Resource<Bucket>,
key_values: Vec<(String, Vec<u8>)>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Set the values associated with the keys in the store. If the key already exists in the
store, it overwrites the value. Read more
Source§fn delete_many<'life0, 'async_trait>(
&'life0 mut self,
bucket: Resource<Bucket>,
keys: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete_many<'life0, 'async_trait>(
&'life0 mut self,
bucket: Resource<Bucket>,
keys: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Delete the key-value pairs associated with the keys in the store. Read more
Source§impl Host for KeyValueDispatch
impl Host for KeyValueDispatch
Source§fn increment<'life0, 'async_trait>(
&'life0 mut self,
bucket: Resource<Bucket>,
key: String,
delta: i64,
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn increment<'life0, 'async_trait>(
&'life0 mut self,
bucket: Resource<Bucket>,
key: String,
delta: i64,
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Atomically increment the value associated with the key in the store by the given delta. It
returns the new value. Read more
Source§fn swap<'life0, 'async_trait>(
&'life0 mut self,
cas_res: Resource<Cas>,
value: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<Result<(), CasError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn swap<'life0, 'async_trait>(
&'life0 mut self,
cas_res: Resource<Cas>,
value: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<Result<(), CasError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Perform the swap on a CAS operation. This consumes the CAS handle and returns an error if
the CAS operation failed.
Source§impl Host for KeyValueDispatch
impl Host for KeyValueDispatch
Source§fn open<'life0, 'async_trait>(
&'life0 mut self,
name: String,
) -> Pin<Box<dyn Future<Output = Result<Result<u32, LegacyError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn open<'life0, 'async_trait>(
&'life0 mut self,
name: String,
) -> Pin<Box<dyn Future<Output = Result<Result<u32, LegacyError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Open the store with the specified name. Read more
Source§fn get<'life0, 'async_trait>(
&'life0 mut self,
store: u32,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Result<Vec<u8>, LegacyError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get<'life0, 'async_trait>(
&'life0 mut self,
store: u32,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Result<Vec<u8>, LegacyError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn set<'life0, 'async_trait>(
&'life0 mut self,
store: u32,
key: String,
value: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<Result<(), LegacyError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set<'life0, 'async_trait>(
&'life0 mut self,
store: u32,
key: String,
value: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<Result<(), LegacyError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Set the
value
associated with the specified key
in the specified
store
, overwriting any existing value. Read moreSource§fn delete<'life0, 'async_trait>(
&'life0 mut self,
store: u32,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Result<(), LegacyError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete<'life0, 'async_trait>(
&'life0 mut self,
store: u32,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Result<(), LegacyError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn exists<'life0, 'async_trait>(
&'life0 mut self,
store: u32,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Result<bool, LegacyError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn exists<'life0, 'async_trait>(
&'life0 mut self,
store: u32,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Result<bool, LegacyError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§impl HostBucket for KeyValueDispatch
impl HostBucket for KeyValueDispatch
Source§fn get<'life0, 'async_trait>(
&'life0 mut self,
self_: Resource<Bucket>,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get<'life0, 'async_trait>(
&'life0 mut self,
self_: Resource<Bucket>,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the value associated with the specified
key
Read moreSource§fn set<'life0, 'async_trait>(
&'life0 mut self,
self_: Resource<Bucket>,
key: String,
value: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set<'life0, 'async_trait>(
&'life0 mut self,
self_: Resource<Bucket>,
key: String,
value: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Set the value associated with the key in the store. If the key already
exists in the store, it overwrites the value. Read more
Source§fn delete<'life0, 'async_trait>(
&'life0 mut self,
self_: Resource<Bucket>,
key: String,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete<'life0, 'async_trait>(
&'life0 mut self,
self_: Resource<Bucket>,
key: String,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Delete the key-value pair associated with the key in the store. Read more
Source§fn exists<'life0, 'async_trait>(
&'life0 mut self,
self_: Resource<Bucket>,
key: String,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn exists<'life0, 'async_trait>(
&'life0 mut self,
self_: Resource<Bucket>,
key: String,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check if the key exists in the store. Read more
Source§fn list_keys<'life0, 'async_trait>(
&'life0 mut self,
self_: Resource<Bucket>,
cursor: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<KeyResponse, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_keys<'life0, 'async_trait>(
&'life0 mut self,
self_: Resource<Bucket>,
cursor: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<KeyResponse, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get all the keys in the store with an optional cursor (for use in pagination). It
returns a list of keys. Please note that for most KeyValue implementations, this is a
can be a very expensive operation and so it should be used judiciously. Implementations
can return any number of keys in a single response, but they should never attempt to
send more data than is reasonable (i.e. on a small edge device, this may only be a few
KB, while on a large machine this could be several MB). Any response should also return
a cursor that can be used to fetch the next page of keys. See the
key-response
record
for more information. Read morefn drop<'life0, 'async_trait>(
&'life0 mut self,
rep: Resource<Bucket>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§impl HostCas for KeyValueDispatch
impl HostCas for KeyValueDispatch
Source§fn new<'life0, 'async_trait>(
&'life0 mut self,
bucket: Resource<Bucket>,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Resource<Cas>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn new<'life0, 'async_trait>(
&'life0 mut self,
bucket: Resource<Bucket>,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Resource<Cas>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Construct a new CAS operation. Implementors can map the underlying functionality
(transactions, versions, etc) as desired.
Source§fn current<'life0, 'async_trait>(
&'life0 mut self,
cas: Resource<Cas>,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn current<'life0, 'async_trait>(
&'life0 mut self,
cas: Resource<Cas>,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the current value of the key (if it exists). This allows for avoiding reads if all
that is needed to ensure the atomicity of the operation
fn drop<'life0, 'async_trait>(
&'life0 mut self,
rep: Resource<Cas>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§impl HostStore for KeyValueDispatch
impl HostStore for KeyValueDispatch
Source§fn open<'life0, 'async_trait>(
&'life0 mut self,
name: String,
) -> Pin<Box<dyn Future<Output = Result<Result<Resource<Store>, Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn open<'life0, 'async_trait>(
&'life0 mut self,
name: String,
) -> Pin<Box<dyn Future<Output = Result<Result<Resource<Store>, Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Open the store with the specified label. Read more
Source§fn get<'life0, 'async_trait>(
&'life0 mut self,
store: Resource<Store>,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Result<Option<Vec<u8>>, Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get<'life0, 'async_trait>(
&'life0 mut self,
store: Resource<Store>,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Result<Option<Vec<u8>>, Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the value associated with the specified
key
Read moreSource§fn set<'life0, 'async_trait>(
&'life0 mut self,
store: Resource<Store>,
key: String,
value: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<Result<(), Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set<'life0, 'async_trait>(
&'life0 mut self,
store: Resource<Store>,
key: String,
value: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<Result<(), Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Set the
value
associated with the specified key
overwriting any existing value.Source§fn delete<'life0, 'async_trait>(
&'life0 mut self,
store: Resource<Store>,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Result<(), Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete<'life0, 'async_trait>(
&'life0 mut self,
store: Resource<Store>,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Result<(), Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Delete the tuple with the specified
key
Read moreSource§fn exists<'life0, 'async_trait>(
&'life0 mut self,
store: Resource<Store>,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Result<bool, Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn exists<'life0, 'async_trait>(
&'life0 mut self,
store: Resource<Store>,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Result<bool, Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Return whether a tuple exists for the specified
key
Source§fn get_keys<'life0, 'async_trait>(
&'life0 mut self,
store: Resource<Store>,
) -> Pin<Box<dyn Future<Output = Result<Result<Vec<String>, Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_keys<'life0, 'async_trait>(
&'life0 mut self,
store: Resource<Store>,
) -> Pin<Box<dyn Future<Output = Result<Result<Vec<String>, Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Return a list of all the keys
fn drop<'life0, 'async_trait>(
&'life0 mut self,
store: Resource<Store>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
impl Host for KeyValueDispatch
Auto Trait Implementations§
impl Freeze for KeyValueDispatch
impl !RefUnwindSafe for KeyValueDispatch
impl Send for KeyValueDispatch
impl Sync for KeyValueDispatch
impl Unpin for KeyValueDispatch
impl !UnwindSafe for KeyValueDispatch
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more