Skip to main content

KvWriter

Trait KvWriter 

Source
pub trait KvWriter: Send + Sync {
    // Required methods
    fn put<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        value: &'life2 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<VersionToken, KvError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool, KvError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn create<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        value: &'life2 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<VersionToken, KvError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn update<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        value: &'life2 [u8],
        expected: &'life3 VersionToken,
    ) -> Pin<Box<dyn Future<Output = Result<VersionToken, KvError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn delete_with_version<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        expected: &'life2 VersionToken,
    ) -> Pin<Box<dyn Future<Output = Result<bool, KvError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

Write operations - optional, edge proxy is primarily read-only.

Required Methods§

Source

fn put<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 str, value: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<VersionToken, KvError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Put a value. Returns the new version token.

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool, KvError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a key. Best-effort: may return true even if the key did not exist (NATS does not report pre-existence). Use get() first if you need to distinguish “deleted something” from “nothing to delete”.

Source

fn create<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 str, value: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<VersionToken, KvError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Create a key only if it doesn’t exist. Returns AlreadyExists if the key has a live value.

Source

fn update<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, key: &'life1 str, value: &'life2 [u8], expected: &'life3 VersionToken, ) -> Pin<Box<dyn Future<Output = Result<VersionToken, KvError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Compare-and-swap: update only if current version matches expected. Returns RevisionMismatch on conflict.

Source

fn delete_with_version<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 str, expected: &'life2 VersionToken, ) -> Pin<Box<dyn Future<Output = Result<bool, KvError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

CAS-gated delete: delete only if current version matches expected. Returns RevisionMismatch on conflict. Writes an empty value (logical delete) so concurrent writers get a conflict.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§