Struct Storage
pub struct Storage<F> { /* private fields */ }
Available on crate feature
storage
only.Expand description
Object holding an instance of a key-value pair storage.
You should probably look into using the global instance accessible via
ariel_os_storage::storage::{get,insert,remove}
.
Implementations§
§impl<F> Storage<F>where
F: NorFlash,
impl<F> Storage<F>where
F: NorFlash,
pub async fn get_raw<V>(
&mut self,
key: &str,
) -> Result<Option<V>, Error<<F as ErrorType>::Error>>where
V: for<'d> Value<'d>,
pub async fn get_raw<V>(
&mut self,
key: &str,
) -> Result<Option<V>, Error<<F as ErrorType>::Error>>where
V: for<'d> Value<'d>,
pub async fn insert_raw<'d, V>(
&mut self,
key: &str,
value: V,
) -> Result<(), Error<<F as ErrorType>::Error>>where
V: Value<'d>,
pub async fn insert_raw<'d, V>(
&mut self,
key: &str,
value: V,
) -> Result<(), Error<<F as ErrorType>::Error>>where
V: Value<'d>,
pub async fn insert<'d, V>(
&mut self,
key: &str,
value: V,
) -> Result<(), Error<<F as ErrorType>::Error>>
pub async fn insert<'d, V>( &mut self, key: &str, value: V, ) -> Result<(), Error<<F as ErrorType>::Error>>
Stores a key-value pair into flash memory.
It will overwrite the last value that has the same key.
§impl<F> Storage<F>where
F: MultiwriteNorFlash,
impl<F> Storage<F>where
F: MultiwriteNorFlash,
pub async fn remove(
&mut self,
key: &str,
) -> Result<(), Error<<F as ErrorType>::Error>>
pub async fn remove( &mut self, key: &str, ) -> Result<(), Error<<F as ErrorType>::Error>>
Deletes an item from flash.
Additional calls to Storage::get()
with the same key will return None
until
a new one is stored again.
This is really slow!
All items in flash have to be read and deserialized to find the items with the key. This is unlikely to be cached well.
§Panics
Currently panics if key.len() > MAX_KEY_LEN
.
Auto Trait Implementations§
impl<F> Freeze for Storage<F>where
F: Freeze,
impl<F> RefUnwindSafe for Storage<F>where
F: RefUnwindSafe,
impl<F> Send for Storage<F>where
F: Send,
impl<F> Sync for Storage<F>where
F: Sync,
impl<F> Unpin for Storage<F>where
F: Unpin,
impl<F> UnwindSafe for Storage<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more