pub trait KVStoreCompareAndSwap: KVStoreDatabase {
// Required method
fn kv_compare_and_swap<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
&'life0 self,
primary_namespace: &'life1 str,
secondary_namespace: &'life2 str,
key: &'life3 str,
expected: Option<&'life4 [u8]>,
replacement: &'life5 [u8],
) -> Pin<Box<dyn Future<Output = Result<bool, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
'life5: 'async_trait;
}Expand description
Key-value store capability for atomic compare-and-swap operations.
This is a separate capability because not every KVStoreDatabase
backend can guarantee an atomic conditional write.
Required Methods§
Sourcefn kv_compare_and_swap<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
&'life0 self,
primary_namespace: &'life1 str,
secondary_namespace: &'life2 str,
key: &'life3 str,
expected: Option<&'life4 [u8]>,
replacement: &'life5 [u8],
) -> Pin<Box<dyn Future<Output = Result<bool, Self::Err>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
'life5: 'async_trait,
fn kv_compare_and_swap<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
&'life0 self,
primary_namespace: &'life1 str,
secondary_namespace: &'life2 str,
key: &'life3 str,
expected: Option<&'life4 [u8]>,
replacement: &'life5 [u8],
) -> Pin<Box<dyn Future<Output = Result<bool, Self::Err>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
'life5: 'async_trait,
Replaces a value only when its current value matches expected.
An expected value of None inserts only when the key does not exist.
Returns true when the value was changed and false when the
expectation did not match.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".