Skip to main content

Storage

Struct Storage 

Source
pub struct Storage<'d> {
    nvs: Nvs<FlashStorage<'d>>,
    hasher: Hasher<'d>,
    config_updated: bool,
}

Fields§

§nvs: Nvs<FlashStorage<'d>>§hasher: Hasher<'d>§config_updated: bool

Implementations§

Source§

impl<'d> Storage<'d>

Source

fn wasm_key_from_name(&mut self, name: &str) -> Key

Source

pub fn new( flash: FLASH<'d>, sha_peripherals: SHA<'d>, ) -> Result<Self, StorageError>

Creates and initialises the storage handle. Reads the partition table from flash to find the "storage" partition and init NVS with the correct offset and size of that partition.

Source

pub fn save_system_config( &mut self, system_config: &SystemConfiguration, ) -> Result<(), StorageError>

Persists the system configuration to NVS.

The write is skipped if there are no changes in the config to avoid flash wear.

Source

pub fn get_system_config(&mut self) -> Result<SystemConfiguration, StorageError>

Reads and deserialises the system configuration, returns a default [SystemConfiguration] if no config has been saved yet (First boot).

Source

pub fn get_system_config_change(&mut self) -> Option<SystemConfiguration>

Only returns the sytem config if there has been a change since the last call to this function, otherwise returns None. used by Renderer to detect config changes.

Source

pub fn save_compiled_widget( &mut self, widget_metadata: WidgetInstallationData, data: &[u8], ) -> Result<(), StorageError>

Writes a widget WASM binary to NVS and adds it to the system config in one call.

Source

pub fn deinstall_widget(&mut self, name: &str) -> Result<(), StorageError>

Removes a widget’s WASM binary from NVS and deletes its entry from the system config.

Source

pub fn config_set(&mut self, key: &str, value: &str) -> Result<(), StorageError>

Stores a key-value string in the "config" NVS namespace.

Source

pub fn config_get(&mut self, key: &str) -> Result<String, StorageError>

Reads a key-value string from the "config" NVS namespace.

Source

pub fn wasm_write( &mut self, name: &str, data: &[u8], ) -> Result<(), StorageError>

Writes a raw WASM binary to the "wasm" NVS namespace.

Source

pub fn wasm_read(&mut self, name: &str) -> Result<Vec<u8>, StorageError>

Reads a previously stored WASM binary from the "wasm" NVS namespace.

Source

pub fn wasm_delete(&mut self, name: &str) -> Result<(), StorageError>

Deletes a WASM binary from the "wasm" NVS namespace.

Source

pub fn list_widgets(&mut self) -> Result<Vec<String>, StorageError>

Returns the names of all installed widgets from the system config.

Auto Trait Implementations§

§

impl<'d> Freeze for Storage<'d>

§

impl<'d> RefUnwindSafe for Storage<'d>

§

impl<'d> Send for Storage<'d>

§

impl<'d> Sync for Storage<'d>

§

impl<'d> Unpin for Storage<'d>

§

impl<'d> UnsafeUnpin for Storage<'d>

§

impl<'d> !UnwindSafe for Storage<'d>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.