Skip to main content

Networks

Trait Networks 

Source
pub trait Networks: MaybeSendSync {
Show 15 methods // Required methods fn max_networks(&self) -> Result<u8, Error>; fn networks( &self, f: &mut dyn FnMut(&[u8]) -> Result<(), Error>, ) -> Result<(), Error>; fn creds( &self, network_id: &[u8], f: &mut dyn FnMut(&WirelessCreds<'_>) -> Result<(), Error>, ) -> Result<u8, NetworksError>; fn next_creds( &self, last_network_id: Option<&[u8]>, f: &mut dyn FnMut(&WirelessCreds<'_>) -> Result<(), Error>, ) -> Result<bool, Error>; fn enabled(&self) -> Result<bool, Error>; fn set_enabled(&mut self, enabled: bool) -> Result<(), Error>; fn add_or_update( &mut self, creds: &WirelessCreds<'_>, ) -> Result<u8, NetworksError>; fn reorder( &mut self, index: u8, network_id: &[u8], ) -> Result<u8, NetworksError>; fn remove(&mut self, network_id: &[u8]) -> Result<u8, NetworksError>; fn managed(&self) -> Result<bool, Error>; fn set_managed(&mut self, managed: bool) -> Result<(), Error>; fn reset(&mut self) -> Result<(), Error>; fn load(&mut self, data: &[u8]) -> Result<(), Error>; fn save(&self, buf: &mut [u8]) -> Result<Option<usize>, Error>; // Provided method fn net_type(&self) -> Option<NetworkType> { ... }
}
Expand description

Trait for managing networks’ credentials storage

Required Methods§

Source

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

Return the maximum number of networks supported by the implementation

For NetworkType::Ethernet this method should always return 1

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

For NetworkType::Ethernet this method should always fail with an error.

The function will be called with the credentials for the network ID, or an error if the network ID is not found.

Return the index of the network ID if found, or an error if not found.

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

For NetworkType::Ethernet this method should always fail with an error.

If the network ID is None or credentials with the provided network ID cannot be found, the first credentials will be returned.

If the credentials corresponding to the network ID are the last ones recorded in the Netwrks trait implementation, the method will wrap-over and will return the first credentials or even the same credentials again if there is only one recorded network.

Return true if the credentials were found, false otherwise.

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

For NetworkType::Ethernet this method should always fail with an error.

The network ID is derived from the credentials.

Return the index of the network ID if it was added or updated, or an error if the operation failed.

Source

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

Reorder the network with the given index

For NetworkType::Ethernet this method should always fail with an error.

The index is the new index of the network ID.

Return the index of the network ID if it was reordered, or an error if the operation failed.

Source

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

Remove the network with the given network ID

For NetworkType::Ethernet this method should always fail with an error.

Return the index of the network ID if it was removed, or an error if the operation failed.

Source

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

Return whether the networks store is in “managed” state.

Managed means: the store holds committed operational network configuration, and the operational connectivity manager (WirelessMgr) may act on it. The store starts unmanaged (never commissioned, empty), and temporarily becomes unmanaged again while network changes are staged under an armed fail-safe (any successful AddOrUpdate*Network / RemoveNetwork / ReorderNetwork / ConnectNetwork flips it to false) - during such a window the commissioner drives connectivity explicitly, and the manager must stand down.

The state comes back to managed on either exit from the window:

  • commit: CommissioningComplete calls set_managed(true) and persists the store;
  • revert: the fail-safe expiry reloads the persisted store, which always carries the committed - hence managed - state.

Note that a window which stages no network changes (e.g. opened only to commission an additional fabric) leaves the store managed, so connectivity maintenance of the operational network continues throughout - matching CHIP’s behavior.

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.

Provided Methods§

Source

fn net_type(&self) -> Option<NetworkType>

Return the type of the networks the store holds, if it knows it.

The default implementation returns None.

Trait Implementations§

Source§

impl Networks for &mut dyn Networks

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

fn net_type(&self) -> Option<NetworkType>

Return the type of the networks the store holds, if it knows it. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> Networks for &mut T
where T: Networks,

Source§

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

Source§

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>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn net_type(&self) -> Option<NetworkType>

Implementors§