[][src]Trait kernel::hil::kv_system::KVSystem

pub trait KVSystem {
    type K: KeyType;
    pub fn set_client(&self, client: &dyn Client<'_, Self::K>);
pub fn generate_key(
        &self,
        unhashed_key: &'static [u8],
        key_buf: &'static Self::K
    ) -> Result<(), (&'static [u8], &'static Self::K, ReturnCode)>;
pub fn append_key(
        &self,
        key: &'static Self::K,
        value: &'static [u8]
    ) -> Result<(), (&'static Self::K, &'static [u8], ReturnCode)>;
pub fn get_value(
        &self,
        key: &'static Self::K,
        ret_buf: &'static mut [u8]
    ) -> Result<(), (&'static Self::K, &'static [u8], ReturnCode)>;
pub fn invalidate_key(
        &self,
        key: &'static Self::K
    ) -> Result<(), (&'static Self::K, ReturnCode)>;
pub fn garbage_collect(&self) -> Result<usize, ReturnCode>; }

Associated Types

type K: KeyType[src]

The type of the hashed key. For example '[u8; 64]'.

Loading content...

Required methods

pub fn set_client(&self, client: &dyn Client<'_, Self::K>)[src]

Set the client

pub fn generate_key(
    &self,
    unhashed_key: &'static [u8],
    key_buf: &'static Self::K
) -> Result<(), (&'static [u8], &'static Self::K, ReturnCode)>
[src]

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 ReturnCode will be returned.

pub fn append_key(
    &self,
    key: &'static Self::K,
    value: &'static [u8]
) -> Result<(), (&'static Self::K, &'static [u8], ReturnCode)>
[src]

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 ReturnCode will be returned.

The possible ReturnCodes are: EBUSY: An operation is already in progress EINVAL: An invalid parameter was passed ENODEVICE: No KV store was setup ENOSUPPORT: The key could not be added due to a collision. ENOMEM: The key could not be added due to no more space.

pub fn get_value(
    &self,
    key: &'static Self::K,
    ret_buf: &'static mut [u8]
) -> Result<(), (&'static Self::K, &'static [u8], ReturnCode)>
[src]

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 ReturnCode will be returned.

The possible ReturnCodes are: EBUSY: An operation is already in progress EINVAL: An invalid parameter was passed ENODEVICE: No KV store was setup ENOSUPPORT: The key could not be found.

pub fn invalidate_key(
    &self,
    key: &'static Self::K
) -> Result<(), (&'static Self::K, ReturnCode)>
[src]

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 ReturnCode will be returned.

The possible ReturnCodes are: EBUSY: An operation is already in progress EINVAL: An invalid parameter was passed ENODEVICE: No KV store was setup ENOSUPPORT: The key could not be found.

pub fn garbage_collect(&self) -> Result<usize, ReturnCode>[src]

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 ReturnCode will be returned.

The possible ReturnCodes are: EBUSY: An operation is already in progress EINVAL: An invalid parameter was passed ENODEVICE: No KV store was setup

Loading content...

Implementors

Loading content...