Skip to main content

FailSafe

Struct FailSafe 

Source
pub struct FailSafe { /* private fields */ }

Implementations§

Source§

impl FailSafe

Source

pub const fn new() -> FailSafe

Source

pub fn init() -> impl Init<FailSafe>

Source

pub fn check_failsafe_timeout<S, N>( &mut self, fabrics: &mut Fabrics, sessions: &mut Sessions, networks: N, kv: S, expire_sess_id: Option<u32>, mdns_notif: impl FnMut(), notify_change: impl FnMut(u16, u32), ) -> Result<Option<NonZero<u8>>, Error>

Check if the fail-safe timer has expired and if so disarms and restores the state of the fabric as well as the basic info settings.

This should be called periodically to ensure that the fail-safe state is updated in a timely manner. Ideally, it should also be called at the beginning of any API that requires the fail-safe to be armed to ensure that the state is up to date.

Returns the local index of the fabric that ended up removed by the rollback (see [Failsafe::expire]), if any - the caller must follow up with a HandlerContext::notify_fabric_removed broadcast once the Matter state lock is released.

Source

pub fn expire<S, N>( &mut self, fabrics: &mut Fabrics, sessions: &mut Sessions, expire_sess_id: Option<u32>, networks: N, kv: S, mdns_notif: impl FnMut(), notify_change: impl FnMut(u16, u32), ) -> Result<Option<NonZero<u8>>, Error>

Force the fail-safe context to expire immediately, rolling back any fabric / network changes that the in-flight commissioning had staged and resetting the breadcrumb to 0.

expire_sess_id is the optional session ID of the exchange that triggered the expiry — typically passed when the trigger arrived over PASE, so the response can still be sent before the slot is reclaimed. None for the timeout-driven path or when the trigger arrived over CASE.

Returns the local index of the fabric the rollback ended up removing, if any: a fabric added by the in-flight AddNOC has no persisted copy yet and is simply dropped, whereas a pre-existing fabric mutated by UpdateNOC is resurrected from its persisted copy (and is thus NOT reported as removed). The caller must follow up with a HandlerContext::notify_fabric_removed broadcast for a reported removal, once the Matter state lock is released.

Source

pub fn arm( &mut self, timeout_secs: u16, breadcrumb: u64, session_mode: &SessionMode, pase: &mut Pase, ) -> Result<(), Error>

Source

pub fn disarm<'a>( &mut self, session_mode: &SessionMode, fabrics: &'a mut Fabrics, ) -> Result<&'a mut Fabric, Error>

Source

pub fn is_armed(&self) -> bool

Source

pub fn pending_root_ca(&self) -> Option<&[u8]>

Return the trusted root certificate that has been staged via AddTrustedRootCertificate while the fail-safe is armed but has not yet been bound to a fabric via AddNOC / UpdateNOC.

Once AddNOC or UpdateNOC is processed the root certificate is owned by the (new or updated) fabric and is reported through the fabric table; until then it has no fabric association but the spec still requires it to appear in the TrustedRootCertificates list (Matter Core spec, NodeOperationalCredentials cluster).

Source

pub fn is_armed_for(&self, caller_fab_idx: u8) -> bool

Source

pub fn has_pending_noc_for(&self, caller_fab_idx: NonZero<u8>) -> bool

Whether the current fail-safe context already has an in-flight AddNOC or UpdateNOC for caller_fab_idx. Used by SetVIDVerificationStatement to decide whether the VID-verification mutation rides along with the pending fabric (and thus rolls back on fail-safe expiry) or is committed to storage immediately.

Source

pub fn check_armed(&self, session_mode: &SessionMode) -> Result<(), Error>

Source

pub fn add_trusted_root_cert<C>( &mut self, crypto: C, time: UtcTime, session_mode: &SessionMode, root_ca: &[u8], buf: &mut [u8], ) -> Result<(), Error>
where C: Crypto,

Source

pub fn add_csr_req<C>( &mut self, crypto: C, session_mode: &SessionMode, ) -> Result<CryptoSensitiveRef<'_, rs_matter::::crypto::canon::CanonPkcSecretKeyRef::{constant#0}>, Error>
where C: Crypto,

Source

pub fn update_csr_req<C>( &mut self, crypto: C, session_mode: &SessionMode, ) -> Result<CryptoSensitiveRef<'_, rs_matter::::crypto::canon::CanonPkcSecretKeyRef::{constant#0}>, Error>
where C: Crypto,

Source

pub fn update_noc<'a, C>( &mut self, crypto: C, time: UtcTime, fabrics: &'a mut Fabrics, session_mode: &SessionMode, icac: Option<&[u8]>, noc: &[u8], buf: &mut [u8], mdns_notif: impl FnMut(), ) -> Result<&'a mut Fabric, Error>
where C: Crypto,

Source

pub fn add_noc<'a, C>( &mut self, crypto: C, time: UtcTime, fabrics: &'a mut Fabrics, session_mode: &SessionMode, vendor_id: u16, icac: Option<&[u8]>, noc: &[u8], ipk: &[u8], case_admin_subject: u64, buf: &mut [u8], mdns_notif: impl FnMut(), ) -> Result<&'a mut Fabric, Error>
where C: Crypto,

Source

pub fn breadcrumb(&self) -> u64

Source

pub fn set_breadcrumb(&mut self, value: u64)

Trait Implementations§

Source§

impl Default for FailSafe

Source§

fn default() -> FailSafe

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

Auto Trait Implementations§

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