Struct tickv::AsyncTicKV

source ·
pub struct AsyncTicKV<'a, C: FlashController<S>, const S: usize> {
    pub tickv: TicKV<'a, C, S>,
    /* private fields */
}
Expand description

The struct storing all of the TicKV information for the async implementation.

Fields§

§tickv: TicKV<'a, C, S>

The main TicKV struct

Implementations§

source§

impl<'a, C: FlashController<S>, const S: usize> AsyncTicKV<'a, C, S>

source

pub fn new( controller: C, read_buffer: &'a mut [u8; S], flash_size: usize, ) -> Self

Create a new struct

C: An implementation of the FlashController trait

controller: An new struct implementing FlashController flash_size: The total size of the flash used for TicKV

source

pub fn initialise(&self, hashed_main_key: u64) -> Result<SuccessCode, ErrorCode>

This function setups the flash region to be used as a key-value store. If the region is already initialised this won’t make any changes.

hashed_main_key: The u64 hash of the const string MAIN_KEY.

If the specified region has not already been setup for TicKV the entire region will be erased.

On success a SuccessCode will be returned. On error a ErrorCode will be returned.

source

pub fn append_key( &self, hash: u64, value: &'static mut [u8], length: usize, ) -> Result<SuccessCode, (&'static mut [u8], ErrorCode)>

Appends the key/value pair to flash storage.

hash: 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 a ErrorCode will be returned.

source

pub fn get_key( &self, hash: u64, buf: &'static mut [u8], ) -> Result<SuccessCode, (&'static mut [u8], ErrorCode)>

Retrieves the value from flash storage.

hash: A hashed key. buf: A buffer to store the value to.

On success a SuccessCode will be returned. On error a ErrorCode will be returned.

If a power loss occurs before success is returned the data is assumed to be lost.

source

pub fn invalidate_key(&self, hash: u64) -> Result<SuccessCode, ErrorCode>

Invalidates the key in flash storage

hash: A hashed key. key: A unhashed key. This will be hashed internally.

On success a SuccessCode will be returned. On error a ErrorCode will be returned.

If a power loss occurs before success is returned the data is assumed to be lost.

source

pub fn zeroise_key(&self, hash: u64) -> Result<SuccessCode, ErrorCode>

Zeroizes the key in flash storage

hash: A hashed key. key: A unhashed key. This will be hashed internally.

On success a SuccessCode will be returned. On error a ErrorCode will be returned.

If a power loss occurs before success is returned the data is assumed to be lost.

source

pub fn garbage_collect(&self) -> Result<SuccessCode, ErrorCode>

Perform a garbage collection on TicKV

On success a SuccessCode will be returned. On error a ErrorCode will be returned.

source

pub fn set_read_buffer(&self, read_buffer: &[u8])

Copy data from read_buffer argument to the internal read_buffer. This should be used to copy the data that the implementation wanted to read when calling read_region after the async operation has completed.

source

pub fn continue_operation( &self, ) -> (Result<SuccessCode, ErrorCode>, Option<&'static mut [u8]>, usize)

Continue the last operation after the async operation has completed. This should be called from a read/erase complete callback. NOTE: If called from a read callback, set_read_buffer should be called first to update the data.

hash_function: Hash function with no previous state. This is usually a newly created hash.

Returns a tuple of 3 values Result: On success a SuccessCode will be returned. On error a ErrorCode will be returned. Buf Buffer: An option of the buf buffer used Length usize: The number of valid bytes in the buffer. 0 if Buf is None. The buffers will only be returned on a non async error or on success.

Auto Trait Implementations§

§

impl<'a, C, const S: usize> !Freeze for AsyncTicKV<'a, C, S>

§

impl<'a, C, const S: usize> !RefUnwindSafe for AsyncTicKV<'a, C, S>

§

impl<'a, C, const S: usize> Send for AsyncTicKV<'a, C, S>
where C: Send,

§

impl<'a, C, const S: usize> !Sync for AsyncTicKV<'a, C, S>

§

impl<'a, C, const S: usize> Unpin for AsyncTicKV<'a, C, S>
where C: Unpin,

§

impl<'a, C, const S: usize> !UnwindSafe for AsyncTicKV<'a, C, S>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.