pub struct FlashStore<F, M>where
F: MultiwriteNorFlash,
M: RawMutex,{ /* private fields */ }Expand description
Owns the flash driver and the sequential-storage map.
Construct once during board init, place in a StaticCell, then hand
&'static references to the view constructors when building the
Mac platform.
Implementations§
Source§impl<F, M> FlashStore<F, M>where
F: MultiwriteNorFlash,
M: RawMutex,
impl<F, M> FlashStore<F, M>where
F: MultiwriteNorFlash,
M: RawMutex,
Sourcepub fn new(flash: F, range: Range<u32>) -> Self
pub fn new(flash: F, range: Range<u32>) -> Self
Wrap an async flash driver over range. Does NOT erase or format
the flash — the underlying map mounts lazily on first access.
range must be page-aligned and at least two pages long;
MapConfig::new panics otherwise. Callers pass a board constant,
so a bad geometry is a boot-time panic rather than a silent
corruption.
Source§impl<F, M> FlashStore<F, M>where
F: MultiwriteNorFlash,
M: RawMutex,
impl<F, M> FlashStore<F, M>where
F: MultiwriteNorFlash,
M: RawMutex,
Sourcepub async fn load_tracker_preferences(
&self,
) -> Result<Option<u8>, Error<F::Error>>
pub async fn load_tracker_preferences( &self, ) -> Result<Option<u8>, Error<F::Error>>
Load the board-independent encoded tracker preferences byte.
Sourcepub async fn store_tracker_preferences(
&self,
value: u8,
) -> Result<(), Error<F::Error>>
pub async fn store_tracker_preferences( &self, value: u8, ) -> Result<(), Error<F::Error>>
Persist the board-independent encoded tracker preferences byte.
Source§impl<F, M> FlashStore<F, M>where
F: MultiwriteNorFlash,
M: RawMutex,
impl<F, M> FlashStore<F, M>where
F: MultiwriteNorFlash,
M: RawMutex,
Sourcepub async fn load_all_peers<const N: usize>(
&self,
out: &mut Vec<([u8; 32], Option<String<MAX_ALIAS_LEN>>), N>,
) -> Result<(), Error<F::Error>>
pub async fn load_all_peers<const N: usize>( &self, out: &mut Vec<([u8; 32], Option<String<MAX_ALIAS_LEN>>), N>, ) -> Result<(), Error<F::Error>>
Load every persisted peer into out.
Each entry is a raw 32-byte public key plus an optional alias string
(up to 16 UTF-8 bytes). Entries beyond N are silently dropped.
Sourcepub async fn store_peer_entry(
&self,
pk: &[u8; 32],
alias: Option<&[u8]>,
) -> Result<(), Error<F::Error>>
pub async fn store_peer_entry( &self, pk: &[u8; 32], alias: Option<&[u8]>, ) -> Result<(), Error<F::Error>>
Upsert the alias for pk.
Writes the alias header and appends pk to the peer index if not
already present. Any previously stored identity bytes are preserved.
alias, if supplied, must be at most MAX_ALIAS_LEN bytes.
Sourcepub async fn update_peer_identity(
&self,
pk: &[u8; 32],
identity_bytes: &[u8],
) -> Result<(), Error<F::Error>>
pub async fn update_peer_identity( &self, pk: &[u8; 32], identity_bytes: &[u8], ) -> Result<(), Error<F::Error>>
Update (or clear) the serialised NodeIdentityPayload for pk.
The alias header is preserved. Pass an empty slice to remove the
identity portion while keeping the alias. The peer must already be in
the peer index (i.e. store_peer_entry called first).
Sourcepub async fn load_peer_identity(
&self,
pk: &[u8; 32],
out: &mut [u8],
) -> Result<Option<usize>, Error<F::Error>>
pub async fn load_peer_identity( &self, pk: &[u8; 32], out: &mut [u8], ) -> Result<Option<usize>, Error<F::Error>>
Load the raw serialised identity bytes for pk into out.
Returns the number of bytes written when an identity record is present,
None when no identity has been stored yet.
Source§impl<F, M> FlashStore<F, M>where
F: MultiwriteNorFlash,
M: RawMutex,
impl<F, M> FlashStore<F, M>where
F: MultiwriteNorFlash,
M: RawMutex,
Sourcepub async fn load_all_channels<const N: usize>(
&self,
out: &mut Vec<(String<MAX_CHANNEL_NAME_LEN>, [u8; 32]), N>,
) -> Result<(), Error<F::Error>>
pub async fn load_all_channels<const N: usize>( &self, out: &mut Vec<(String<MAX_CHANNEL_NAME_LEN>, [u8; 32]), N>, ) -> Result<(), Error<F::Error>>
Load every persisted channel into out.
Each entry is a name string (up to 16 UTF-8 bytes) and a 32-byte key.
Entries beyond N are silently dropped.