pub struct LevelControlHandler<'a, H, OH>where
H: LevelControlHooks,
OH: OnOffHooks,{ /* 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>where
H: LevelControlHooks,
impl<H> LevelControlHandler<'_, H, NoOnOff>where
H: LevelControlHooks,
Sourcepub fn new_standalone(
dataver: Dataver,
endpoint_id: u16,
hooks: H,
attribute_defaults: AttributeDefaults,
) -> LevelControlHandler<'_, H, NoOnOff>
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>where
H: LevelControlHooks,
OH: OnOffHooks,
impl<'a, H, OH> LevelControlHandler<'a, H, OH>where
H: LevelControlHooks,
OH: OnOffHooks,
Sourcepub fn new(
dataver: Dataver,
endpoint_id: u16,
hooks: H,
attribute_defaults: AttributeDefaults,
) -> LevelControlHandler<'a, H, OH>
pub fn new( dataver: Dataver, endpoint_id: u16, hooks: H, attribute_defaults: AttributeDefaults, ) -> LevelControlHandler<'a, H, OH>
Sourcepub fn with_scene_invalidator(
self,
invalidator: &'a dyn SceneInvalidator,
) -> LevelControlHandler<'a, H, OH>
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.
Sourcepub fn init(&self, on_off_handler: Option<&'a OnOffHandler<'a, OH, H>>)
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.
Sourcepub const fn adapt(self) -> HandlerAsyncAdaptor<LevelControlHandler<'a, H, OH>>
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>where
H: LevelControlHooks,
OH: OnOffHooks,
impl<H, OH> ClusterAsyncHandler for LevelControlHandler<'_, H, OH>where
H: LevelControlHooks,
OH: OnOffHooks,
Source§const CLUSTER: Cluster<'static> = H::CLUSTER
const CLUSTER: Cluster<'static> = H::CLUSTER
async fn run(&self, ctx: impl HandlerContext) -> Result<(), Error>
fn dataver(&self) -> u32
fn dataver_changed(&self)
fn current_level( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<Maybe<u8, AsNullable>, Error>>
fn on_level( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<Maybe<u8, AsNullable>, Error>>
fn set_on_level( &self, ctx: impl WriteContext, value: Maybe<u8, AsNullable>, ) -> impl Future<Output = Result<(), Error>>
fn options( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<OptionsBitmap, Error>>
fn set_options( &self, ctx: impl WriteContext, value: OptionsBitmap, ) -> impl Future<Output = Result<(), Error>>
fn remaining_time( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<u16, Error>>
fn max_level( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<u8, Error>>
fn min_level( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<u8, Error>>
fn on_off_transition_time( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<u16, Error>>
fn set_on_off_transition_time( &self, ctx: impl WriteContext, value: u16, ) -> impl Future<Output = Result<(), Error>>
fn on_transition_time( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<Maybe<u16, AsNullable>, Error>>
fn set_on_transition_time( &self, ctx: impl WriteContext, value: Maybe<u16, AsNullable>, ) -> impl Future<Output = Result<(), Error>>
fn off_transition_time( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<Maybe<u16, AsNullable>, Error>>
fn set_off_transition_time( &self, ctx: impl WriteContext, value: Maybe<u16, AsNullable>, ) -> impl Future<Output = Result<(), Error>>
fn default_move_rate( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<Maybe<u8, AsNullable>, Error>>
fn set_default_move_rate( &self, ctx: impl WriteContext, value: Maybe<u8, AsNullable>, ) -> impl Future<Output = Result<(), Error>>
fn start_up_current_level( &self, _ctx: impl ReadContext, ) -> impl Future<Output = Result<Maybe<u8, AsNullable>, Error>>
fn set_start_up_current_level( &self, ctx: impl WriteContext, value: Maybe<u8, AsNullable>, ) -> impl Future<Output = Result<(), Error>>
fn handle_move_to_level( &self, _ctx: impl InvokeContext, request: MoveToLevelRequest<'_>, ) -> impl Future<Output = Result<(), Error>>
fn handle_move( &self, _ctx: impl InvokeContext, request: MoveRequest<'_>, ) -> impl Future<Output = Result<(), Error>>
fn handle_step( &self, _ctx: impl InvokeContext, request: StepRequest<'_>, ) -> impl Future<Output = Result<(), Error>>
fn handle_stop( &self, ctx: impl InvokeContext, request: StopRequest<'_>, ) -> impl Future<Output = Result<(), Error>>
fn handle_move_to_level_with_on_off( &self, _ctx: impl InvokeContext, request: MoveToLevelWithOnOffRequest<'_>, ) -> impl Future<Output = Result<(), Error>>
fn handle_move_with_on_off( &self, _ctx: impl InvokeContext, request: MoveWithOnOffRequest<'_>, ) -> impl Future<Output = Result<(), Error>>
fn handle_step_with_on_off( &self, _ctx: impl InvokeContext, request: StepWithOnOffRequest<'_>, ) -> impl Future<Output = Result<(), Error>>
fn handle_stop_with_on_off( &self, ctx: impl InvokeContext, request: StopWithOnOffRequest<'_>, ) -> impl Future<Output = Result<(), Error>>
fn handle_move_to_closest_frequency( &self, _ctx: impl InvokeContext, _request: MoveToClosestFrequencyRequest<'_>, ) -> impl Future<Output = Result<(), Error>>
fn lifecycle( &self, _ctx: impl HandlerContext, _op: LifecycleOp, ) -> Result<(), Error>
fn current_frequency( &self, ctx: impl ReadContext, ) -> impl Future<Output = Result<u16, Error>>
fn min_frequency( &self, ctx: impl ReadContext, ) -> impl Future<Output = Result<u16, Error>>
fn max_frequency( &self, ctx: impl ReadContext, ) -> impl Future<Output = Result<u16, Error>>
Source§impl<H, OH> SceneClusterHandler for LevelControlHandler<'_, H, OH>where
H: LevelControlHooks,
OH: OnOffHooks,
Scenes Management integration for the LevelControl cluster. The
only scenable attribute is CurrentLevel; apply routes through
MoveToLevel with the scene’s transition time.
impl<H, OH> SceneClusterHandler for LevelControlHandler<'_, H, OH>where
H: LevelControlHooks,
OH: OnOffHooks,
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
const CLUSTER_ID: u32
Source§fn endpoint_id(&self) -> u16
fn endpoint_id(&self) -> u16
StoreScene / RecallScene target endpoint.Source§fn is_scenable_attribute(attribute_id: u32) -> bool
fn is_scenable_attribute(attribute_id: u32) -> bool
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>where
P: TLVBuilderParent,
fn capture<P>(
&self,
avp_array: AttributeValuePairStructArrayBuilder<P>,
) -> Result<AttributeValuePairStructArrayBuilder<P>, Error>where
P: TLVBuilderParent,
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,
async fn apply<C>(
&self,
_ctx: &C,
avp_list: &TLVContainer<'_, AttributeValuePairStruct<'_>, ArrayContainer>,
transition_time_ms: u32,
) -> Result<(), Error>where
C: HandlerContext,
core::future::ready. Read moreAuto 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> 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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