pub trait KVSystem<'a> {
    type K: KeyType;

    fn set_client(&self, client: &'a dyn Client<Self::K>);
    fn generate_key(
        &self,
        unhashed_key: &'static mut [u8],
        key_buf: &'static mut Self::K
    ) -> Result<(), (&'static mut [u8], &'static mut Self::K, Result<(), ErrorCode>)>; fn append_key(
        &self,
        key: &'static mut Self::K,
        value: &'static mut [u8]
    ) -> Result<(), (&'static mut Self::K, &'static mut [u8], Result<(), ErrorCode>)>; fn get_value(
        &self,
        key: &'static mut Self::K,
        ret_buf: &'static mut [u8]
    ) -> Result<(), (&'static mut Self::K, &'static mut [u8], Result<(), ErrorCode>)>; fn invalidate_key(
        &self,
        key: &'static mut Self::K
    ) -> Result<(), (&'static mut Self::K, Result<(), ErrorCode>)>; fn garbage_collect(&self) -> Result<usize, Result<(), ErrorCode>>; }

Required Associated Types

The type of the hashed key. For example ‘[u8; 8]’.

Required Methods

Set the client

Generate key

unhashed_key: A unhashed key that should be hashed. key_buf: A buffer to store the hashed key output.

On success returns nothing. On error the unhashed_key, key_buf and Result<(), ErrorCode> will be returned.

Appends the key/value pair.

key: A hashed key. This key will be used in future to retrieve or remove the value. value: A buffer containing the data to be stored to flash.

On success nothing will be returned. On error the key, value and a Result<(), ErrorCode> will be returned.

The possible Result<(), ErrorCode>s are: BUSY: An operation is already in progress INVAL: An invalid parameter was passed NODEVICE: No KV store was setup ENOSUPPORT: The key could not be added due to a collision. NOMEM: The key could not be added due to no more space.

Retrieves the value from a specified key.

key: A hashed key. This key will be used to retrieve the value. ret_buf: A buffer to store the value to.

On success nothing will be returned. On error the key, ret_buf and a Result<(), ErrorCode> will be returned.

The possible Result<(), ErrorCode>s are: BUSY: An operation is already in progress INVAL: An invalid parameter was passed NODEVICE: No KV store was setup ENOSUPPORT: The key could not be found.

Invalidates the key in flash storage

key: A hashed key. This key will be used to remove the value.

On success nothing will be returned. On error the key and a Result<(), ErrorCode> will be returned.

The possible Result<(), ErrorCode>s are: BUSY: An operation is already in progress INVAL: An invalid parameter was passed NODEVICE: No KV store was setup ENOSUPPORT: The key could not be found.

Perform a garbage collection on the KV Store

For implementations that don’t require garbage collecting this can just be a NOP that returns ‘Ok(0)’.

On success the number of bytes freed will be returned. On error a Result<(), ErrorCode> will be returned.

The possible Result<(), ErrorCode>s are: BUSY: An operation is already in progress INVAL: An invalid parameter was passed NODEVICE: No KV store was setup

Implementors