Skip to main content

LevelControlHandler

Struct LevelControlHandler 

Source
pub struct LevelControlHandler<'a, H, OH>{ /* private fields */ }
Expand description

Implementation of the LevelControlHandler, providing functionality for the Matter Level Control cluster.

§Type Parameters

  • 'a: Lifetime for references held by the cluster.
  • H: Handler implementing the LevelControlHooks trait, providing cluster-specific configuration and logic.
  • OH : Handler implementing the OnOffHooks trait.

§Constants

  • MAXIMUM_LEVEL: The maximum allowed level value (254).

§Panics

  • Initialisation panics if the cluster configuration is invalid or required attributes/commands are missing.

§Notes

  • This implementation follows version 1.3 of the Matter specification.

Implementations§

Source§

impl<H> LevelControlHandler<'_, H, NoOnOff>

Source

pub fn new_standalone( dataver: Dataver, endpoint_id: u16, hooks: H, attribute_defaults: AttributeDefaults, ) -> LevelControlHandler<'_, H, NoOnOff>

Creates a new LevelControlHandler with the given hooks which is not coupled to an OnOff cluster.

NOTE: This constructor automatically calls init with no coupled OnOff handler.

§Arguments
  • hooks - A reference to the struct implementing the device-specific level control logic.
Source§

impl<'a, H, OH> LevelControlHandler<'a, H, OH>

Source

pub fn new( dataver: Dataver, endpoint_id: u16, hooks: H, attribute_defaults: AttributeDefaults, ) -> LevelControlHandler<'a, H, OH>

Creates a new LevelControlHandler with the given hooks.

§Arguments
  • hooks - A reference to the struct implementing the device-specific level control logic.
§Usage
  • Initialise and optionally couple with an OnOff handler via init.
Source

pub fn with_scene_invalidator( self, invalidator: &'a dyn SceneInvalidator, ) -> LevelControlHandler<'a, H, OH>

Attach a SceneInvalidator — typically the crate::dm::clusters::scenes::ScenesState backing Scenes Management on the same endpoint — so command-driven CurrentLevel mutations flip SceneValid → false for any recalled scene. No-op when unset.

Source

pub fn init(&self, on_off_handler: Option<&'a OnOffHandler<'a, OH, H>>)

Initializes the cluster on startup;

  • wire coupled handlers
  • validate the handler setup with the configuration
  • set the CurrentLevel attribute according to the StartUpCurrentLevel attribute.
§Parameters

*on_off_handler: the OnOffHandler instance coupled with this LevelControlHandler, i.e. the OnOff cluster on the same endpoint. This should be set if the OnOff feature is set.

§Panics

panics if the state’s CLUSTER is misconfigured.

Source

pub const fn adapt(self) -> HandlerAsyncAdaptor<LevelControlHandler<'a, H, OH>>

Adapt the handler instance to the generic rs-matter Handler trait

Trait Implementations§

Source§

impl<H, OH> ClusterAsyncHandler for LevelControlHandler<'_, H, OH>

Source§

const CLUSTER: Cluster<'static> = H::CLUSTER

The cluster-metadata corresponding to this handler trait.
Source§

async fn run(&self, ctx: impl HandlerContext) -> Result<(), Error>

Source§

fn dataver(&self) -> u32

Source§

fn dataver_changed(&self)

Source§

fn current_level( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<Maybe<u8, AsNullable>, Error>>

Source§

fn on_level( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<Maybe<u8, AsNullable>, Error>>

Source§

fn set_on_level( &self, ctx: impl WriteContext, value: Maybe<u8, AsNullable>, ) -> impl Future<Output = Result<(), Error>>

Source§

fn options( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<OptionsBitmap, Error>>

Source§

fn set_options( &self, ctx: impl WriteContext, value: OptionsBitmap, ) -> impl Future<Output = Result<(), Error>>

Source§

fn remaining_time( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<u16, Error>>

Source§

fn max_level( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<u8, Error>>

Source§

fn min_level( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<u8, Error>>

Source§

fn on_off_transition_time( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<u16, Error>>

Source§

fn set_on_off_transition_time( &self, ctx: impl WriteContext, value: u16, ) -> impl Future<Output = Result<(), Error>>

Source§

fn on_transition_time( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<Maybe<u16, AsNullable>, Error>>

Source§

fn set_on_transition_time( &self, ctx: impl WriteContext, value: Maybe<u16, AsNullable>, ) -> impl Future<Output = Result<(), Error>>

Source§

fn off_transition_time( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<Maybe<u16, AsNullable>, Error>>

Source§

fn set_off_transition_time( &self, ctx: impl WriteContext, value: Maybe<u16, AsNullable>, ) -> impl Future<Output = Result<(), Error>>

Source§

fn default_move_rate( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<Maybe<u8, AsNullable>, Error>>

Source§

fn set_default_move_rate( &self, ctx: impl WriteContext, value: Maybe<u8, AsNullable>, ) -> impl Future<Output = Result<(), Error>>

Source§

fn start_up_current_level( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<Maybe<u8, AsNullable>, Error>>

Source§

fn set_start_up_current_level( &self, ctx: impl WriteContext, value: Maybe<u8, AsNullable>, ) -> impl Future<Output = Result<(), Error>>

Source§

fn handle_move_to_level( &self, _ctx: impl InvokeContext, request: MoveToLevelRequest<'_>, ) -> impl Future<Output = Result<(), Error>>

Source§

fn handle_move( &self, _ctx: impl InvokeContext, request: MoveRequest<'_>, ) -> impl Future<Output = Result<(), Error>>

Source§

fn handle_step( &self, _ctx: impl InvokeContext, request: StepRequest<'_>, ) -> impl Future<Output = Result<(), Error>>

Source§

fn handle_stop( &self, ctx: impl InvokeContext, request: StopRequest<'_>, ) -> impl Future<Output = Result<(), Error>>

Source§

fn handle_move_to_level_with_on_off( &self, _ctx: impl InvokeContext, request: MoveToLevelWithOnOffRequest<'_>, ) -> impl Future<Output = Result<(), Error>>

Source§

fn handle_move_with_on_off( &self, _ctx: impl InvokeContext, request: MoveWithOnOffRequest<'_>, ) -> impl Future<Output = Result<(), Error>>

Source§

fn handle_step_with_on_off( &self, _ctx: impl InvokeContext, request: StepWithOnOffRequest<'_>, ) -> impl Future<Output = Result<(), Error>>

Source§

fn handle_stop_with_on_off( &self, ctx: impl InvokeContext, request: StopWithOnOffRequest<'_>, ) -> impl Future<Output = Result<(), Error>>

Source§

fn handle_move_to_closest_frequency( &self, _ctx: impl InvokeContext, _request: MoveToClosestFrequencyRequest<'_>, ) -> impl Future<Output = Result<(), Error>>

Source§

fn lifecycle( &self, _ctx: impl HandlerContext, _op: LifecycleOp, ) -> Result<(), Error>

Source§

fn current_frequency( &self, ctx: impl ReadContext, ) -> impl Future<Output = Result<u16, Error>>

Source§

fn min_frequency( &self, ctx: impl ReadContext, ) -> impl Future<Output = Result<u16, Error>>

Source§

fn max_frequency( &self, ctx: impl ReadContext, ) -> impl Future<Output = Result<u16, Error>>

Source§

impl<H, OH> SceneClusterHandler for LevelControlHandler<'_, H, OH>

Scenes Management integration for the LevelControl cluster. The only scenable attribute is CurrentLevel; apply routes through MoveToLevel with the scene’s transition time.

Source§

const CLUSTER_ID: u32

The Matter cluster ID this impl handles.
Source§

fn endpoint_id(&self) -> u16

Endpoint this handler instance is installed on. Used to skip clusters not on the StoreScene / RecallScene target endpoint.
Source§

fn is_scenable_attribute(attribute_id: u32) -> bool

True if attribute_id is a scenable attribute of this cluster per the Matter Core Spec. AddScene rejects EFS payloads that reference non-scenable attributes.
Source§

fn capture<P>( &self, avp_array: AttributeValuePairStructArrayBuilder<P>, ) -> Result<AttributeValuePairStructArrayBuilder<P>, Error>

Emit AVP entries for this cluster’s scenable state into avp_array. Use AttributeValuePairStructArrayBuilder::push_u8 / AttributeValuePairStructArrayBuilder::push_u16 for a one-line per-attribute API.
Source§

async fn apply<C>( &self, _ctx: &C, avp_list: &TLVContainer<'_, AttributeValuePairStruct<'_>, ArrayContainer>, transition_time_ms: u32, ) -> Result<(), Error>
where C: HandlerContext,

Apply captured AVPs to the cluster’s internal state. Async because some clusters (LevelControl) kick off transition tasks; sync-only impls can return core::future::ready. Read more

Auto Trait Implementations§

§

impl<'a, H, OH> !Freeze for LevelControlHandler<'a, H, OH>

§

impl<'a, H, OH> !RefUnwindSafe for LevelControlHandler<'a, H, OH>

§

impl<'a, H, OH> !Send for LevelControlHandler<'a, H, OH>

§

impl<'a, H, OH> !Sync for LevelControlHandler<'a, H, OH>

§

impl<'a, H, OH> !UnwindSafe for LevelControlHandler<'a, H, OH>

§

impl<'a, H, OH> Unpin for LevelControlHandler<'a, H, OH>
where H: Unpin,

§

impl<'a, H, OH> UnsafeUnpin for LevelControlHandler<'a, H, OH>
where H: UnsafeUnpin,

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