pub struct FailSafe { /* private fields */ }Implementations§
Source§impl FailSafe
impl FailSafe
pub const fn new() -> Self
pub fn init() -> impl Init<Self>
Sourcepub fn set_max_cumulative_secs(&mut self, secs: u16)
pub fn set_max_cumulative_secs(&mut self, secs: u16)
Set MaxCumulativeFailsafeSeconds, the longest a fail-safe context
lasts however often it is re-armed. Applies to the contexts created
from now on: an armed one keeps its lifetime.
Sourcepub fn check_failsafe_timeout<S>(
&mut self,
fabrics: &mut Fabrics,
remove_pase_sessions: impl FnOnce(),
kv: S,
mdns_notif: impl FnMut(),
notify_change: impl FnMut(EndptId, ClusterId),
) -> Result<Option<Expiry>, Error>where
S: KvBlobStoreAccess,
pub fn check_failsafe_timeout<S>(
&mut self,
fabrics: &mut Fabrics,
remove_pase_sessions: impl FnOnce(),
kv: S,
mdns_notif: impl FnMut(),
notify_change: impl FnMut(EndptId, ClusterId),
) -> Result<Option<Expiry>, Error>where
S: KvBlobStoreAccess,
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 outcome of the expiry, if the fail-safe did expire (see
FailSafe::expire).
Sourcepub fn expire<S>(
&mut self,
fabrics: &mut Fabrics,
remove_pase_sessions: impl FnOnce(),
kv: S,
mdns_notif: impl FnMut(),
notify_change: impl FnMut(EndptId, ClusterId),
) -> Result<Option<Expiry>, Error>where
S: KvBlobStoreAccess,
pub fn expire<S>(
&mut self,
fabrics: &mut Fabrics,
remove_pase_sessions: impl FnOnce(),
kv: S,
mdns_notif: impl FnMut(),
notify_change: impl FnMut(EndptId, ClusterId),
) -> Result<Option<Expiry>, Error>where
S: KvBlobStoreAccess,
Force the fail-safe context to expire immediately, rolling back any fabric changes that the in-flight commissioning had staged and resetting the breadcrumb to 0.
remove_pase_sessions removes the PASE sessions, which are orphaned by
the rollback. When the trigger arrived over PASE, it should keep the
session of the triggering exchange alive (marked expired), so that the
response can still be sent before the slot is reclaimed.
Returns None if the fail-safe was not armed. Otherwise, the caller
must broadcast LifecycleOp::FailSafeExpiry once the Matter state lock
is released, so that the handlers drop what they staged (networks and
the like), and HandlerContext::notify_fabric_removed for the
returned removed fabric. That is a fabric added by the in-flight
AddNOC, which has no persisted copy yet; a pre-existing fabric
mutated by UpdateNOC is resurrected from its persisted copy instead.
pub fn arm( &mut self, timeout_secs: u16, breadcrumb: u64, session_mode: &SessionMode, comm_window_open: bool, ) -> Result<(), Error>
pub fn disarm<'a>( &mut self, session_mode: &SessionMode, fabrics: &'a mut Fabrics, ) -> Result<&'a mut Fabric, Error>
Sourcepub fn disarm_with<'a, F>(
&mut self,
session_mode: &SessionMode,
fabrics: &'a mut Fabrics,
commit: F,
) -> Result<&'a mut Fabric, Error>
pub fn disarm_with<'a, F>( &mut self, session_mode: &SessionMode, fabrics: &'a mut Fabrics, commit: F, ) -> Result<&'a mut Fabric, Error>
Like Self::disarm, running commit on the fabric first. If commit
fails, the fail-safe stays armed, for its expiry to revert the fabric.
Sourcepub fn expires_at(&self) -> Option<Instant>
pub fn expires_at(&self) -> Option<Instant>
When the armed fail-safe expires, or None if it is not armed.
pub fn is_armed(&self) -> bool
Sourcepub fn pending_root_ca(&self) -> Option<&[u8]>
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).
Sourcepub fn drop_pending_root_ca(&mut self)
pub fn drop_pending_root_ca(&mut self)
Drop the trusted root certificate staged via AddTrustedRootCertificate,
if no AddNOC / UpdateNOC has bound it to a fabric yet.
For fabric removal: the root is then not referenced by any operational
certificate, so it must go. The fail-safe stays armed, and another
AddTrustedRootCertificate in it is still refused.
pub fn is_armed_for(&self, caller_fab_idx: u8) -> bool
Sourcepub fn has_pending_noc_for(&self, caller_fab_idx: NonZeroU8) -> bool
pub fn has_pending_noc_for(&self, caller_fab_idx: NonZeroU8) -> 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.
pub fn check_armed(&self, session_mode: &SessionMode) -> Result<(), Error>
pub fn add_trusted_root_cert<C: Crypto>( &mut self, crypto: C, time: UtcTime, session_mode: &SessionMode, root_ca: &[u8], buf: &mut [u8], ) -> Result<(), Error>
pub fn add_csr_req<C: Crypto>( &mut self, crypto: C, session_mode: &SessionMode, ) -> Result<CanonPkcSecretKeyRef<'_>, Error>
pub fn update_csr_req<C: Crypto>( &mut self, crypto: C, session_mode: &SessionMode, ) -> Result<CanonPkcSecretKeyRef<'_>, Error>
pub fn update_noc<'a, C: Crypto>( &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>
pub fn add_noc<'a, C: Crypto>( &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>
Sourcepub fn pending_add_noc(&self) -> Option<(NonZeroU8, u16)>
pub fn pending_add_noc(&self) -> Option<(NonZeroU8, u16)>
The fabric added by AddNOC in the current fail-safe context and the
seconds left until expiry; None if there is no such fabric.
Sourcepub fn arm_resumed(
&mut self,
fab_idx: NonZeroU8,
timeout_secs: u16,
breadcrumb: u64,
) -> Result<(), Error>
pub fn arm_resumed( &mut self, fab_idx: NonZeroU8, timeout_secs: u16, breadcrumb: u64, ) -> Result<(), Error>
Arm the fail-safe for a fabric resumed from a commissioning handover,
as if AddNOC had just been processed for it. Busy if already armed.
Sourcepub fn check_new_noc<C: Crypto>(
crypto: &C,
time: UtcTime,
fabrics: &Fabrics,
root_ca: &[u8],
icac: Option<&[u8]>,
noc: &[u8],
secret_key: CanonPkcSecretKeyRef<'_>,
buf: &mut [u8],
) -> Result<(), Error>
pub fn check_new_noc<C: Crypto>( crypto: &C, time: UtcTime, fabrics: &Fabrics, root_ca: &[u8], icac: Option<&[u8]>, noc: &[u8], secret_key: CanonPkcSecretKeyRef<'_>, buf: &mut [u8], ) -> Result<(), Error>
Check that a NOC is acceptable for a new fabric: the chain verifies
against root_ca, the NOC public key matches secret_key, and no
existing fabric has the same fabric ID under the same root.
Trait Implementations§
Auto Trait Implementations§
impl Forget for FailSafe
impl Freeze for FailSafe
impl Move for FailSafe
impl RefUnwindSafe for FailSafe
impl Send for FailSafe
impl Sync for FailSafe
impl Unpin for FailSafe
impl UnsafeUnpin for FailSafe
impl UnwindSafe for FailSafe
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
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