Skip to main content

WirelessNetworks

Struct WirelessNetworks 

Source
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,

Source

pub const fn new() -> WirelessNetworks<N, T>

Source

pub fn init() -> impl Init<WirelessNetworks<N, T>>

Source

pub fn reset(&mut self)

Reset the state

Source

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 from
  • buf: a temporary buffer to use for removing the networks
Source

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 from
  • buf: a temporary buffer to use for loading the networks
Source

pub fn load(&mut self, data: &[u8]) -> Result<(), Error>

Load the state from a byte slice.

§Arguments
  • data: The byte slice to load the state from
Source

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.

Source

pub fn networks<F>(&self, f: F) -> Result<(), Error>
where F: FnMut(&T) -> Result<(), Error>,

Iterate over the registered network credentials

§Arguments
  • f: A closure that will be called for each network registered in the storage
Source

pub fn network<F>(&self, network_id: &[u8], f: F) -> Result<u8, NetworksError>
where F: FnOnce(&T) -> Result<(), Error>,

Get the credentials of a network by its ID

§Arguments
  • network_id: The ID of the network to get
  • f: 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

Source

pub fn next_network<F>( &self, last_network_id: Option<&[u8]>, f: F, ) -> Result<bool, Error>
where F: FnOnce(&T) -> Result<(), 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.
Source

pub fn add_or_update<A, U>( &mut self, network_id: &[u8], add: A, update: U, ) -> Result<u8, NetworksError>
where A: Init<T, Error>, U: FnOnce(&mut T) -> Result<(), Error>,

Add or update a network in the storage

§Arguments
  • network_id: The ID of the network to add or update
  • add: 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 storage
  • update: 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
Source

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 network
  • network_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

Source

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

Source

pub fn managed(&self) -> bool

Source

pub fn set_managed(&mut self, managed: bool)

Trait Implementations§

Source§

impl<const N: usize, T> Clone for WirelessNetworks<N, T>
where T: Clone,

Source§

fn clone(&self) -> WirelessNetworks<N, T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize, T> Debug for WirelessNetworks<N, T>
where T: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<const N: usize, T> Default for WirelessNetworks<N, T>
where T: WirelessNetwork,

Source§

fn default() -> WirelessNetworks<N, T>

Returns the “default value” for a type. Read more
Source§

impl<const N: usize, T> Networks for WirelessNetworks<N, T>
where T: WirelessNetwork,

Source§

fn max_networks(&self) -> Result<u8, Error>

Return the maximum number of networks supported by the implementation Read more
Source§

fn networks( &self, f: &mut dyn FnMut(&[u8]) -> Result<(), Error>, ) -> Result<(), Error>

Iterate over the networks recorded in the implementation and call the provided function for each network
Source§

fn creds( &self, network_id: &[u8], f: &mut dyn FnMut(&WirelessCreds<'_>) -> Result<(), Error>, ) -> Result<u8, NetworksError>

Get the credentials for the given network ID by calling the provided function Read more
Source§

fn next_creds( &self, last_network_id: Option<&[u8]>, f: &mut dyn FnMut(&WirelessCreds<'_>) -> Result<(), Error>, ) -> Result<bool, Error>

Return the next credentials after the ones corresponding to the given network ID by calling the provided function Read more
Source§

fn enabled(&self) -> Result<bool, Error>

Return whether the network interface is enabled
Source§

fn set_enabled(&mut self, _enabled: bool) -> Result<(), Error>

Set the network interface enabled or disabled
Source§

fn add_or_update( &mut self, creds: &WirelessCreds<'_>, ) -> Result<u8, NetworksError>

Add or update the credentials for the given network ID Read more
Source§

fn reorder(&mut self, index: u8, network_id: &[u8]) -> Result<u8, NetworksError>

Reorder the network with the given index Read more
Source§

fn remove(&mut self, network_id: &[u8]) -> Result<u8, NetworksError>

Remove the network with the given network ID Read more
Source§

fn managed(&self) -> Result<bool, Error>

Return whether the networks store is in “managed” state. Read more
Source§

fn set_managed(&mut self, managed: bool) -> Result<(), Error>

Set the managed state of the networks store (see managed).
Source§

fn reset(&mut self) -> Result<(), Error>

Reset the networks to the initial state, removing all recorded network credentials
Source§

fn load(&mut self, data: &[u8]) -> Result<(), Error>

Load the networks’ credentials from the given data
Source§

fn save(&self, buf: &mut [u8]) -> Result<Option<usize>, Error>

Save the networks’ credentials into the given buffer and return the number of bytes written or None if the networks do not need persistence.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, E> Init<T, E> for T

Source§

unsafe fn __init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
Source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
Source§

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

Source§

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, I> IntoFallibleInit<T> for I
where I: Init<T>,

Source§

fn into_fallible<E>(self) -> impl Init<T, E>

Convert the infallible initializer to a fallible one.
Source§

impl<Source, Target> OctetsInto<Target> for Source
where Target: OctetsFrom<Source>,

Source§

type Error = <Target as OctetsFrom<Source>>::Error

Source§

fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>

Performs the conversion.
Source§

fn octets_into(self) -> Target
where Self::Error: Into<Infallible>,

Performs an infallible conversion.
Source§

impl<T, E> PinInit<T, E> for T

Source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
Source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

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

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

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V