pub trait KV<'a> {
// Required methods
fn set_client(&self, client: &'a dyn KVClient);
fn get(
&self,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>;
fn set(
&self,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>;
fn add(
&self,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>;
fn update(
&self,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>;
fn delete(
&self,
key: SubSliceMut<'static, u8>,
) -> Result<(), (SubSliceMut<'static, u8>, ErrorCode)>;
}
Expand description
Key-Value interface.
This interface provides access to key-value storage.
KV
includes five typical commands:
get(key) -> value
set(key, value)
add(key, value)
update(key, value)
delete(key)
Required Methods§
sourcefn set_client(&self, client: &'a dyn KVClient)
fn set_client(&self, client: &'a dyn KVClient)
Configure the client for operation callbacks.
sourcefn get(
&self,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>
fn get( &self, key: SubSliceMut<'static, u8>, value: SubSliceMut<'static, u8>, ) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>
Retrieve a value based on the given key.
§Arguments
key
: The key to identify the k-v pair.value
: Where the returned value buffer will be stored.
§Return
- On success returns
Ok(())
. A callback will be issued. - On error, returns the buffers and:
BUSY
: An operation is already in progress.FAIL
: An internal error occurred and the operation cannot be completed.
sourcefn set(
&self,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>
fn set( &self, key: SubSliceMut<'static, u8>, value: SubSliceMut<'static, u8>, ) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>
Store a value based on the given key. If the key does not exist it will be added. If the key already exists the value will be updated.
The value
buffer must have room for a header.
§Arguments
key
: The key to identify the k-v pair.value
: The value to store.
§Return
- On success returns
Ok(())
. A callback will be issued. - On error, returns the buffers and:
BUSY
: An operation is already in progress.SIZE
: The key/value is too large to store.FAIL
: An internal error occurred and the operation cannot be completed.
sourcefn add(
&self,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>
fn add( &self, key: SubSliceMut<'static, u8>, value: SubSliceMut<'static, u8>, ) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>
Store a new value based on the given key. If the key does not exist it will be added. If the key already exists an error callback will be provided.
The value
buffer must have room for a header.
§Arguments
key
: The key to identify the k-v pair.value
: The value to store.
§Return
- On success returns
Ok(())
. A callback will be issued. - On error, returns the buffers and:
BUSY
: An operation is already in progress.SIZE
: The key/value is too large to store.FAIL
: An internal error occurred and the operation cannot be completed.
sourcefn update(
&self,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>
fn update( &self, key: SubSliceMut<'static, u8>, value: SubSliceMut<'static, u8>, ) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>
Modify a value based on the given key. If the key does not exist it an error callback will be provided.
The value
buffer must have room for a header.
§Arguments
key
: The key to identify the k-v pair.value
: The value to store.
§Return
- On success returns
Ok(())
. A callback will be issued. - On error, returns the buffers and:
BUSY
: An operation is already in progress.SIZE
: The key/value is too large to store.FAIL
: An internal error occurred and the operation cannot be completed.
sourcefn delete(
&self,
key: SubSliceMut<'static, u8>,
) -> Result<(), (SubSliceMut<'static, u8>, ErrorCode)>
fn delete( &self, key: SubSliceMut<'static, u8>, ) -> Result<(), (SubSliceMut<'static, u8>, ErrorCode)>
Delete a key-value object based on the given key.
§Arguments
key
: The key to identify the k-v pair.
§Return
- On success returns
Ok(())
. A callback will be issued. - On error, returns the buffers and:
BUSY
: An operation is already in progress.FAIL
: An internal error occurred and the operation cannot be completed.