pub struct Storage<'d> {
nvs: Nvs<FlashStorage<'d>>,
hasher: Hasher<'d>,
config_updated: bool,
}Fields§
§nvs: Nvs<FlashStorage<'d>>§hasher: Hasher<'d>§config_updated: boolImplementations§
Source§impl<'d> Storage<'d>
impl<'d> Storage<'d>
fn wasm_key_from_name(&mut self, name: &str) -> Key
Sourcepub fn new(
flash: FLASH<'d>,
sha_peripherals: SHA<'d>,
) -> Result<Self, StorageError>
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.
Sourcepub fn save_system_config(
&mut self,
system_config: &SystemConfiguration,
) -> Result<(), StorageError>
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.
Sourcepub fn get_system_config(&mut self) -> Result<SystemConfiguration, StorageError>
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).
Sourcepub fn get_system_config_change(&mut self) -> Option<SystemConfiguration>
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.
Sourcepub fn save_compiled_widget(
&mut self,
widget_metadata: WidgetInstallationData,
data: &[u8],
) -> Result<(), StorageError>
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.
Sourcepub fn deinstall_widget(&mut self, name: &str) -> Result<(), StorageError>
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.
Sourcepub fn config_set(&mut self, key: &str, value: &str) -> Result<(), StorageError>
pub fn config_set(&mut self, key: &str, value: &str) -> Result<(), StorageError>
Stores a key-value string in the "config" NVS namespace.
Sourcepub fn config_get(&mut self, key: &str) -> Result<String, StorageError>
pub fn config_get(&mut self, key: &str) -> Result<String, StorageError>
Reads a key-value string from the "config" NVS namespace.
Sourcepub fn wasm_write(
&mut self,
name: &str,
data: &[u8],
) -> Result<(), StorageError>
pub fn wasm_write( &mut self, name: &str, data: &[u8], ) -> Result<(), StorageError>
Writes a raw WASM binary to the "wasm" NVS namespace.
Sourcepub fn wasm_read(&mut self, name: &str) -> Result<Vec<u8>, StorageError>
pub fn wasm_read(&mut self, name: &str) -> Result<Vec<u8>, StorageError>
Reads a previously stored WASM binary from the "wasm" NVS namespace.
Sourcepub fn wasm_delete(&mut self, name: &str) -> Result<(), StorageError>
pub fn wasm_delete(&mut self, name: &str) -> Result<(), StorageError>
Deletes a WASM binary from the "wasm" NVS namespace.
Sourcepub fn list_widgets(&mut self) -> Result<Vec<String>, StorageError>
pub fn list_widgets(&mut self) -> Result<Vec<String>, StorageError>
Returns the names of all installed widgets from the system config.