Skip to main content

Binding

Struct Binding 

Source
pub struct Binding<C: Config, const N: usize> { /* private fields */ }
Expand description

The Binding cluster’s table (§9.6.6.1).

N is the total across every fabric; §9.6.1 asks that a device type’s minimum be available “for each fabric the node supports”, which is what Binding::per_fabric enforces.

Implementations§

Source§

impl<C: Config, const N: usize> Binding<C, N>

Source

pub const fn new(per_fabric: usize) -> Self

A table with no bindings — §9.6.6’s fallback of [].

per_fabric is how many entries any one fabric may hold, so that the first fabric to fill the table cannot leave a later one unable to bind anything.

Source

pub const fn per_fabric(&self) -> usize

The per-fabric quota.

Source

pub fn targets(&self) -> Ref<'_, Vec<Target, N>>

Every binding, for a device about to persist them.

Source

pub fn len_of_fabric(&self, fabric: FabricIndex) -> usize

How many bindings one fabric holds.

Source

pub fn add(&self, target: Target) -> Result<(), Status>

Adds one binding.

§9.6.1: “If, during the creation of multiple bindings, there are no available resources to create an entry … the client SHALL respond with a status of RESOURCE_EXHAUSTED, and the binding SHALL NOT be created.”

Source

pub fn remove_fabric(&self, fabric: FabricIndex)

Removes every binding of one fabric — what RemoveFabric must do.

§9.6.1: “When a binding is removed, the client endpoint SHALL end the binding relationship with the removed binding target.” Ending it is the application’s; this is the table’s half.

Trait Implementations§

Source§

impl<C: Config, const N: usize> Cluster for Binding<C, N>

Source§

const ID: ClusterId = ID

The cluster id this implementation serves.
Source§

impl<C: Config, const N: usize> ClusterHandler for Binding<C, N>

Source§

fn on_lifecycle(&self, event: Lifecycle)

§9.6: the Binding table is fabric-scoped (F), so a removed fabric’s targets go with it — otherwise this node keeps trying to reach a peer on a fabric it has left.

Source§

fn read( &self, resolved: &Resolved<'_>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

Writes the value of resolved’s attribute under tag. Read more
Source§

fn write( &self, resolved: &Resolved<'_>, data: &[u8], op: WriteOp, ctx: &InteractionContext<'_>, ) -> Result<(), Status>

Writes data — the encoded TLV element, tag included — into the attribute. Read more
Source§

fn data_version(&self, _resolved: &Resolved<'_>) -> Option<u32>

The cluster instance’s data version (§7.10.3), if it tracks one. Read more
Source§

fn invoke( &self, _resolved: &ResolvedCommand<'_>, _fields: Option<&[u8]>, _ctx: &InteractionContext<'_>, _w: &mut TlvWriter<'_>, _tag: Tag, ) -> Result<Option<CommandId>, StatusIb>

Runs a command. Read more
Source§

impl<C: Debug + Config, const N: usize> Debug for Binding<C, N>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<C, const N: usize> !Freeze for Binding<C, N>

§

impl<C, const N: usize> !RefUnwindSafe for Binding<C, N>

§

impl<C, const N: usize> !Sync for Binding<C, N>

§

impl<C, const N: usize> Forget for Binding<C, N>

§

impl<C, const N: usize> Move for Binding<C, N>

§

impl<C, const N: usize> Send for Binding<C, N>
where RefCell<VecInner<Target, usize, VecStorageInner<[MaybeUninit<Target>; N]>>>: Send, PhantomData<C>: Send,

§

impl<C, const N: usize> Unpin for Binding<C, N>
where RefCell<VecInner<Target, usize, VecStorageInner<[MaybeUninit<Target>; N]>>>: Unpin, PhantomData<C>: Unpin,

§

impl<C, const N: usize> UnsafeUnpin for Binding<C, N>

§

impl<C, const N: usize> UnwindSafe for Binding<C, N>

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.