pub trait KVPermissions<'a> {
// Required methods
fn set_client(&self, client: &'a dyn KVClient);
fn get(
&self,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
permissions: StoragePermissions,
) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>;
fn set(
&self,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
permissions: StoragePermissions,
) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>;
fn add(
&self,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
permissions: StoragePermissions,
) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>;
fn update(
&self,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
permissions: StoragePermissions,
) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>;
fn delete(
&self,
key: SubSliceMut<'static, u8>,
permissions: StoragePermissions,
) -> Result<(), (SubSliceMut<'static, u8>, ErrorCode)>;
fn header_size(&self) -> usize;
}
Expand description
Key-Value interface with permissions.
This interface provides access to key-value storage with access control.
Each object is marked with a write_id
(based on the StoragePermissions
used to create it), and all further accesses and modifications to that
object require suitable permissions.
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>,
permissions: StoragePermissions,
) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>
fn get( &self, key: SubSliceMut<'static, u8>, value: SubSliceMut<'static, u8>, permissions: StoragePermissions, ) -> 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.permissions
: The read/write/modify permissions for this access.
§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>,
permissions: StoragePermissions,
) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>
fn set( &self, key: SubSliceMut<'static, u8>, value: SubSliceMut<'static, u8>, permissions: StoragePermissions, ) -> 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. The provided buffer MUST startKVPermissions.header_size()
bytes after the beginning of the buffer to enable the implementation to insert a header.permissions
: The read/write/modify permissions for this access.
§Return
- On success returns
Ok(())
. A callback will be issued. - On error, returns the buffers and:
BUSY
: An operation is already in progress.SIZE
: There is insufficient room to include the permission header in thevalue
buffer or the key/value is too large to store.INVAL
: The caller does not have write permissions.FAIL
: An internal error occurred and the operation cannot be completed.
Sourcefn add(
&self,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
permissions: StoragePermissions,
) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>
fn add( &self, key: SubSliceMut<'static, u8>, value: SubSliceMut<'static, u8>, permissions: StoragePermissions, ) -> 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. The provided buffer MUST startKVPermissions.header_size()
bytes after the beginning of the buffer to enable the implementation to insert a header.permissions
: The read/write/modify permissions for this access.
§Return
- On success returns
Ok(())
. A callback will be issued. - On error, returns the buffers and:
BUSY
: An operation is already in progress.SIZE
: There is insufficient room to include the permission header in thevalue
buffer or the key/value is too large to store.INVAL
: The caller does not have write permissions.FAIL
: An internal error occurred and the operation cannot be completed.
Sourcefn update(
&self,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
permissions: StoragePermissions,
) -> Result<(), (SubSliceMut<'static, u8>, SubSliceMut<'static, u8>, ErrorCode)>
fn update( &self, key: SubSliceMut<'static, u8>, value: SubSliceMut<'static, u8>, permissions: StoragePermissions, ) -> 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. The provided buffer MUST startKVPermissions.header_size()
bytes after the beginning of the buffer to enable the implementation to insert a header.permissions
: The read/write/modify permissions for this access.
§Return
- On success returns
Ok(())
. A callback will be issued. - On error, returns the buffers and:
BUSY
: An operation is already in progress.SIZE
: There is insufficient room to include the permission header in thevalue
buffer or the key/value is too large to store.INVAL
: The caller does not have write permissions.FAIL
: An internal error occurred and the operation cannot be completed.
Sourcefn delete(
&self,
key: SubSliceMut<'static, u8>,
permissions: StoragePermissions,
) -> Result<(), (SubSliceMut<'static, u8>, ErrorCode)>
fn delete( &self, key: SubSliceMut<'static, u8>, permissions: StoragePermissions, ) -> 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.permissions
: The read/write/modify permissions for this access.
§Return
- On success returns
Ok(())
. A callback will be issued. - On error, returns the buffers and:
BUSY
: An operation is already in progress.INVAL
: The caller does not have modify permissions.FAIL
: An internal error occurred and the operation cannot be completed.
Sourcefn header_size(&self) -> usize
fn header_size(&self) -> usize
Returns the length of the key-value store’s header in bytes.
Room for this header must be accommodated in a set
, add
, or update
operation.