KeyValueStore

Trait KeyValueStore 

Source
pub trait KeyValueStore: Store {
    // Required methods
    fn all(&self) -> HashMap<String, Vec<u8>>;
    fn put<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        key: &'life1 str,
        value: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = Result<Operation, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Operation, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Uma store que se comporta como um banco de dados chave-valor distribuído. Herda todas as funcionalidades da trait Store e adiciona operações específicas para pares chave-valor com semântica CRDT.

Todas as operações são replicadas automaticamente através da rede e mantêm consistência eventual entre os peers.

Required Methods§

Source

fn all(&self) -> HashMap<String, Vec<u8>>

Retorna todos os pares chave-valor da store em um mapa. Esta operação lê o estado atual do índice local.

Source

fn put<'life0, 'life1, 'async_trait>( &'life0 mut self, key: &'life1 str, value: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<Operation, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Define um valor para uma chave específica. Cria uma nova operação PUT no log distribuído que será replicada.

§Argumentos
  • key - A chave para associar ao valor (não pode estar vazia)
  • value - Os dados binários a serem armazenados
§Retorna

A operação PUT criada, ou erro se a operação falhar

Source

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

Remove uma chave e seu valor associado. Cria uma nova operação DEL no log distribuído que será replicada.

§Argumentos
  • key - A chave a ser removida
§Retorna

A operação DEL criada, ou erro se a chave não existir ou operação falhar

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Obtém o valor associado a uma chave. Consulta o índice local para o estado mais recente.

§Argumentos
  • key - A chave a ser procurada
§Retorna

Some(Vec<u8>) se a chave existir, None se não existir, ou erro se houver falha no acesso

Implementors§