pub struct WirelessNetworks<const N: usize, T> { /* private fields */ }Expand description
A fixed-size storage for wireless networks credentials.
Implementations§
Source§impl<const N: usize, T> WirelessNetworks<N, T>where
T: WirelessNetwork,
impl<const N: usize, T> WirelessNetworks<N, T>where
T: WirelessNetwork,
pub const fn new() -> WirelessNetworks<N, T>
pub fn init() -> impl Init<WirelessNetworks<N, T>>
Sourcepub async fn reset_persist<S>(
&mut self,
kv: S,
buf: &mut [u8],
) -> Result<(), Error>where
S: KvBlobStore,
pub async fn reset_persist<S>(
&mut self,
kv: S,
buf: &mut [u8],
) -> Result<(), Error>where
S: KvBlobStore,
Remove all networks from the provided BLOB store and from memory
§Arguments
store: the BLOB store to remove the networks frombuf: a temporary buffer to use for removing the networks
Sourcepub async fn load_persist<S>(
&mut self,
kv: S,
buf: &mut [u8],
) -> Result<(), Error>where
S: KvBlobStore,
pub async fn load_persist<S>(
&mut self,
kv: S,
buf: &mut [u8],
) -> Result<(), Error>where
S: KvBlobStore,
Load all networks from the provided BLOB store
§Arguments
store: the BLOB store to load the networks frombuf: a temporary buffer to use for loading the networks
Sourcepub fn store(&self, buf: &mut [u8]) -> Result<usize, Error>
pub fn store(&self, buf: &mut [u8]) -> Result<usize, Error>
Store the state into a byte slice.
§Arguments
buf: The byte slice to store the state into
Returns the number of bytes written into the buffer.
Sourcepub fn networks<F>(&self, f: F) -> Result<(), Error>
pub fn networks<F>(&self, f: F) -> Result<(), Error>
Iterate over the registered network credentials
§Arguments
f: A closure that will be called for each network registered in the storage
Sourcepub fn network<F>(&self, network_id: &[u8], f: F) -> Result<u8, NetworksError>
pub fn network<F>(&self, network_id: &[u8], f: F) -> Result<u8, NetworksError>
Get the credentials of a network by its ID
§Arguments
network_id: The ID of the network to getf: A closure that will be called with the credentials of the network, if the network exists
Returns the index of the network in the storage if the network exists, NetworkError::NetworkIdNotFound otherwise
Sourcepub fn next_network<F>(
&self,
last_network_id: Option<&[u8]>,
f: F,
) -> Result<bool, Error>
pub fn next_network<F>( &self, last_network_id: Option<&[u8]>, f: F, ) -> Result<bool, Error>
Get the next network credentials after the one with the given ID
§Arguments
after_network_id: The ID of the network to get the next one after. If no network with the provided network ID exists, the first network in the storage will be returned.
Sourcepub fn add_or_update<A, U>(
&mut self,
network_id: &[u8],
add: A,
update: U,
) -> Result<u8, NetworksError>
pub fn add_or_update<A, U>( &mut self, network_id: &[u8], add: A, update: U, ) -> Result<u8, NetworksError>
Add or update a network in the storage
§Arguments
network_id: The ID of the network to add or updateadd: An in-place initializer for the network to add. The initializer will be used only if a network with the provided network ID does not exist in the storageupdate: A closure that will be called with the network to update. The closure will be called only if a network with the provided network ID exists in the storage
Sourcepub fn reorder(
&mut self,
index: u8,
network_id: &[u8],
) -> Result<u8, NetworksError>
pub fn reorder( &mut self, index: u8, network_id: &[u8], ) -> Result<u8, NetworksError>
Reorder a network in the storage
§Arguments
index: The new index of the networknetwork_id: The ID of the network to reorder
Returns the new index of the network in the storage, if a network with the provided ID exists
or NetworkError::NetworkIdNotFound otherwise
Sourcepub fn remove(&mut self, network_id: &[u8]) -> Result<u8, NetworksError>
pub fn remove(&mut self, network_id: &[u8]) -> Result<u8, NetworksError>
Remove a network from the storage
§Arguments
network_id: The ID of the network to remove
Returns the index of the network in the storage if the network exists and was removed, NetworkError::NetworkIdNotFound otherwise
pub fn managed(&self) -> bool
pub fn set_managed(&mut self, managed: bool)
Trait Implementations§
Source§impl<const N: usize, T> Clone for WirelessNetworks<N, T>where
T: Clone,
impl<const N: usize, T> Clone for WirelessNetworks<N, T>where
T: Clone,
Source§fn clone(&self) -> WirelessNetworks<N, T>
fn clone(&self) -> WirelessNetworks<N, T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<const N: usize, T> Default for WirelessNetworks<N, T>where
T: WirelessNetwork,
impl<const N: usize, T> Default for WirelessNetworks<N, T>where
T: WirelessNetwork,
Source§fn default() -> WirelessNetworks<N, T>
fn default() -> WirelessNetworks<N, T>
Source§impl<const N: usize, T> Networks for WirelessNetworks<N, T>where
T: WirelessNetwork,
impl<const N: usize, T> Networks for WirelessNetworks<N, T>where
T: WirelessNetwork,
Source§fn max_networks(&self) -> Result<u8, Error>
fn max_networks(&self) -> Result<u8, Error>
Source§fn networks(
&self,
f: &mut dyn FnMut(&[u8]) -> Result<(), Error>,
) -> Result<(), Error>
fn networks( &self, f: &mut dyn FnMut(&[u8]) -> Result<(), Error>, ) -> Result<(), Error>
Source§fn creds(
&self,
network_id: &[u8],
f: &mut dyn FnMut(&WirelessCreds<'_>) -> Result<(), Error>,
) -> Result<u8, NetworksError>
fn creds( &self, network_id: &[u8], f: &mut dyn FnMut(&WirelessCreds<'_>) -> Result<(), Error>, ) -> Result<u8, NetworksError>
Source§fn next_creds(
&self,
last_network_id: Option<&[u8]>,
f: &mut dyn FnMut(&WirelessCreds<'_>) -> Result<(), Error>,
) -> Result<bool, Error>
fn next_creds( &self, last_network_id: Option<&[u8]>, f: &mut dyn FnMut(&WirelessCreds<'_>) -> Result<(), Error>, ) -> Result<bool, Error>
Source§fn set_enabled(&mut self, _enabled: bool) -> Result<(), Error>
fn set_enabled(&mut self, _enabled: bool) -> Result<(), Error>
Source§fn add_or_update(
&mut self,
creds: &WirelessCreds<'_>,
) -> Result<u8, NetworksError>
fn add_or_update( &mut self, creds: &WirelessCreds<'_>, ) -> Result<u8, NetworksError>
Source§fn reorder(&mut self, index: u8, network_id: &[u8]) -> Result<u8, NetworksError>
fn reorder(&mut self, index: u8, network_id: &[u8]) -> Result<u8, NetworksError>
Source§fn remove(&mut self, network_id: &[u8]) -> Result<u8, NetworksError>
fn remove(&mut self, network_id: &[u8]) -> Result<u8, NetworksError>
Source§fn managed(&self) -> Result<bool, Error>
fn managed(&self) -> Result<bool, Error>
Source§fn set_managed(&mut self, managed: bool) -> Result<(), Error>
fn set_managed(&mut self, managed: bool) -> Result<(), Error>
managed).Source§fn reset(&mut self) -> Result<(), Error>
fn reset(&mut self) -> Result<(), Error>
Auto Trait Implementations§
impl<const N: usize, T> Freeze for WirelessNetworks<N, T>where
T: Freeze,
impl<const N: usize, T> RefUnwindSafe for WirelessNetworks<N, T>where
T: RefUnwindSafe,
impl<const N: usize, T> Send for WirelessNetworks<N, T>where
T: Send,
impl<const N: usize, T> Sync for WirelessNetworks<N, T>where
T: Sync,
impl<const N: usize, T> Unpin for WirelessNetworks<N, T>where
T: Unpin,
impl<const N: usize, T> UnsafeUnpin for WirelessNetworks<N, T>where
T: UnsafeUnpin,
impl<const N: usize, T> UnwindSafe for WirelessNetworks<N, T>where
T: 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more