pub trait ClientPersistence {
// Required methods
fn open(&mut self, client_id: &str, server_uri: &str) -> Result<()>;
fn close(&mut self) -> Result<()>;
fn put(&mut self, key: &str, buffers: Vec<&[u8]>) -> Result<()>;
fn get(&mut self, key: &str) -> Result<Vec<u8>>;
fn remove(&mut self, key: &str) -> Result<()>;
fn keys(&mut self) -> Result<Vec<String>>;
fn clear(&mut self) -> Result<()>;
fn contains_key(&mut self, key: &str) -> bool;
}
Expand description
Trait to implement custom persistence in the client.
Required Methods§
sourcefn open(&mut self, client_id: &str, server_uri: &str) -> Result<()>
fn open(&mut self, client_id: &str, server_uri: &str) -> Result<()>
Open and initialize the persistent store.
client_id
The unique client identifier.
server_uri
The address of the server to which the client is
connected.
sourcefn put(&mut self, key: &str, buffers: Vec<&[u8]>) -> Result<()>
fn put(&mut self, key: &str, buffers: Vec<&[u8]>) -> Result<()>
Put data into the persistence store.
key
The key to the data.
buffers
The data to place into the store. Note that these can be
concatenated into a single, contiguous unit if helpful.
sourcefn get(&mut self, key: &str) -> Result<Vec<u8>>
fn get(&mut self, key: &str) -> Result<Vec<u8>>
Gets data from the persistence store.
key
They key for the desired data.
sourcefn remove(&mut self, key: &str) -> Result<()>
fn remove(&mut self, key: &str) -> Result<()>
Removes data for the specified key.
key
The key for the data to remove.
sourcefn keys(&mut self) -> Result<Vec<String>>
fn keys(&mut self) -> Result<Vec<String>>
Gets the keys that are currently in the persistence store
sourcefn clear(&mut self) -> Result<()>
fn clear(&mut self) -> Result<()>
Clear the persistence store so that it no longer contains any data.
sourcefn contains_key(&mut self, key: &str) -> bool
fn contains_key(&mut self, key: &str) -> bool
Determines if the persistence store contains the key.
key
The key to look for.