Skip to content

Commit 528fe92

Browse files
committed
Go back to having a SyncHandler which has sync methods, wrapped by an AsyncClusterHandler
This allows for a cluster to easily combine both sync methods + async methods, while reducing the size of the binary
1 parent 93e70a9 commit 528fe92

20 files changed

Lines changed: 4856 additions & 2173 deletions

File tree

examples/src/bin/bridge.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,10 @@ impl bridged_device_basic_information::ClusterHandler for BridgedHandler {
288288
fn dataver_changed(&self) {
289289
self.dataver.changed();
290290
}
291+
}
291292

292-
async fn reachable(&self, _ctx: impl ReadContext) -> Result<bool, Error> {
293+
impl bridged_device_basic_information::ClusterSyncHandler for BridgedHandler {
294+
fn reachable(&self, _ctx: impl ReadContext) -> Result<bool, Error> {
293295
// This is the only mandatory attribute.
294296
//
295297
// We always report that the bridged device is reachable,
@@ -298,15 +300,15 @@ impl bridged_device_basic_information::ClusterHandler for BridgedHandler {
298300
Ok(true)
299301
}
300302

301-
async fn unique_id<P: TLVBuilderParent>(
303+
fn unique_id<P: TLVBuilderParent>(
302304
&self,
303305
_ctx: impl ReadContext,
304306
_builder: Utf8StrBuilder<P>,
305307
) -> Result<P, Error> {
306308
todo!()
307309
}
308310

309-
async fn handle_keep_active(
311+
fn handle_keep_active(
310312
&self,
311313
_ctx: impl InvokeContext,
312314
_request: KeepActiveRequest<'_>,

examples/src/bin/media_player.rs

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,17 @@ impl media_playback::ClusterHandler for MediaHandler {
268268
fn dataver_changed(&self) {
269269
self.dataver.changed();
270270
}
271+
}
271272

272-
async fn current_state(
273+
impl media_playback::ClusterSyncHandler for MediaHandler {
274+
fn current_state(
273275
&self,
274276
_ctx: impl ReadContext,
275277
) -> Result<media_playback::PlaybackStateEnum, Error> {
276278
Ok(self.state.get())
277279
}
278280

279-
async fn handle_play<P: TLVBuilderParent>(
281+
fn handle_play<P: TLVBuilderParent>(
280282
&self,
281283
ctx: impl InvokeContext,
282284
response: media_playback::PlaybackResponseBuilder<P>,
@@ -288,7 +290,7 @@ impl media_playback::ClusterHandler for MediaHandler {
288290
response.status(StatusEnum::Success)?.data(None)?.end()
289291
}
290292

291-
async fn handle_pause<P: TLVBuilderParent>(
293+
fn handle_pause<P: TLVBuilderParent>(
292294
&self,
293295
ctx: impl InvokeContext,
294296
response: PlaybackResponseBuilder<P>,
@@ -300,7 +302,7 @@ impl media_playback::ClusterHandler for MediaHandler {
300302
response.status(StatusEnum::Success)?.data(None)?.end()
301303
}
302304

303-
async fn handle_stop<P: TLVBuilderParent>(
305+
fn handle_stop<P: TLVBuilderParent>(
304306
&self,
305307
ctx: impl InvokeContext,
306308
response: PlaybackResponseBuilder<P>,
@@ -312,7 +314,7 @@ impl media_playback::ClusterHandler for MediaHandler {
312314
response.status(StatusEnum::Success)?.data(None)?.end()
313315
}
314316

315-
async fn handle_start_over<P: TLVBuilderParent>(
317+
fn handle_start_over<P: TLVBuilderParent>(
316318
&self,
317319
_ctx: impl InvokeContext,
318320
_response: PlaybackResponseBuilder<P>,
@@ -321,7 +323,7 @@ impl media_playback::ClusterHandler for MediaHandler {
321323
Err(ErrorCode::InvalidCommand.into())
322324
}
323325

324-
async fn handle_previous<P: TLVBuilderParent>(
326+
fn handle_previous<P: TLVBuilderParent>(
325327
&self,
326328
_ctx: impl InvokeContext,
327329
_response: PlaybackResponseBuilder<P>,
@@ -330,7 +332,7 @@ impl media_playback::ClusterHandler for MediaHandler {
330332
Err(ErrorCode::InvalidCommand.into())
331333
}
332334

333-
async fn handle_next<P: TLVBuilderParent>(
335+
fn handle_next<P: TLVBuilderParent>(
334336
&self,
335337
_ctx: impl InvokeContext,
336338
_response: PlaybackResponseBuilder<P>,
@@ -339,7 +341,7 @@ impl media_playback::ClusterHandler for MediaHandler {
339341
Err(ErrorCode::InvalidCommand.into())
340342
}
341343

342-
async fn handle_rewind<P: TLVBuilderParent>(
344+
fn handle_rewind<P: TLVBuilderParent>(
343345
&self,
344346
_ctx: impl InvokeContext,
345347
_request: RewindRequest<'_>,
@@ -349,7 +351,7 @@ impl media_playback::ClusterHandler for MediaHandler {
349351
Err(ErrorCode::InvalidCommand.into())
350352
}
351353

352-
async fn handle_fast_forward<P: TLVBuilderParent>(
354+
fn handle_fast_forward<P: TLVBuilderParent>(
353355
&self,
354356
_ctx: impl InvokeContext,
355357
_request: FastForwardRequest<'_>,
@@ -359,7 +361,7 @@ impl media_playback::ClusterHandler for MediaHandler {
359361
Err(ErrorCode::InvalidCommand.into())
360362
}
361363

362-
async fn handle_skip_forward<P: TLVBuilderParent>(
364+
fn handle_skip_forward<P: TLVBuilderParent>(
363365
&self,
364366
_ctx: impl InvokeContext,
365367
_request: SkipForwardRequest<'_>,
@@ -369,7 +371,7 @@ impl media_playback::ClusterHandler for MediaHandler {
369371
Err(ErrorCode::InvalidCommand.into())
370372
}
371373

372-
async fn handle_skip_backward<P: TLVBuilderParent>(
374+
fn handle_skip_backward<P: TLVBuilderParent>(
373375
&self,
374376
_ctx: impl InvokeContext,
375377
_request: SkipBackwardRequest<'_>,
@@ -379,7 +381,7 @@ impl media_playback::ClusterHandler for MediaHandler {
379381
Err(ErrorCode::InvalidCommand.into())
380382
}
381383

382-
async fn handle_seek<P: TLVBuilderParent>(
384+
fn handle_seek<P: TLVBuilderParent>(
383385
&self,
384386
_ctx: impl InvokeContext,
385387
_request: SeekRequest<'_>,
@@ -389,7 +391,7 @@ impl media_playback::ClusterHandler for MediaHandler {
389391
Err(ErrorCode::InvalidCommand.into())
390392
}
391393

392-
async fn handle_activate_audio_track(
394+
fn handle_activate_audio_track(
393395
&self,
394396
_ctx: impl InvokeContext,
395397
_request: ActivateAudioTrackRequest<'_>,
@@ -398,7 +400,7 @@ impl media_playback::ClusterHandler for MediaHandler {
398400
Err(ErrorCode::InvalidCommand.into())
399401
}
400402

401-
async fn handle_activate_text_track(
403+
fn handle_activate_text_track(
402404
&self,
403405
_ctx: impl InvokeContext,
404406
_request: ActivateTextTrackRequest<'_>,
@@ -407,7 +409,7 @@ impl media_playback::ClusterHandler for MediaHandler {
407409
Err(ErrorCode::InvalidCommand.into())
408410
}
409411

410-
async fn handle_deactivate_text_track(&self, _ctx: impl InvokeContext) -> Result<(), Error> {
412+
fn handle_deactivate_text_track(&self, _ctx: impl InvokeContext) -> Result<(), Error> {
411413
// Not supported
412414
Err(ErrorCode::InvalidCommand.into())
413415
}
@@ -444,8 +446,10 @@ impl content_launcher::ClusterHandler for ContentHandler {
444446
fn dataver_changed(&self) {
445447
self.dataver.changed();
446448
}
449+
}
447450

448-
async fn accept_header<P: TLVBuilderParent>(
451+
impl content_launcher::ClusterSyncHandler for ContentHandler {
452+
fn accept_header<P: TLVBuilderParent>(
449453
&self,
450454
_ctx: impl ReadContext,
451455
builder: ArrayAttributeRead<Utf8StrArrayBuilder<P>, Utf8StrBuilder<P>>,
@@ -488,14 +492,14 @@ impl content_launcher::ClusterHandler for ContentHandler {
488492
}
489493
}
490494

491-
async fn supported_streaming_protocols(
495+
fn supported_streaming_protocols(
492496
&self,
493497
_ctx: impl ReadContext,
494498
) -> Result<SupportedProtocolsBitmap, Error> {
495499
Ok(SupportedProtocolsBitmap::all())
496500
}
497501

498-
async fn handle_launch_url<P: TLVBuilderParent>(
502+
fn handle_launch_url<P: TLVBuilderParent>(
499503
&self,
500504
_ctx: impl InvokeContext,
501505
request: LaunchURLRequest<'_>,
@@ -509,7 +513,7 @@ impl content_launcher::ClusterHandler for ContentHandler {
509513
.end()
510514
}
511515

512-
async fn handle_launch_content<P: TLVBuilderParent>(
516+
fn handle_launch_content<P: TLVBuilderParent>(
513517
&self,
514518
_ctx: impl InvokeContext,
515519
request: LaunchContentRequest<'_>,
@@ -552,8 +556,10 @@ impl keypad_input::ClusterHandler for KeypadInputHandler {
552556
fn dataver_changed(&self) {
553557
self.dataver.changed();
554558
}
559+
}
555560

556-
async fn handle_send_key<P: TLVBuilderParent>(
561+
impl keypad_input::ClusterSyncHandler for KeypadInputHandler {
562+
fn handle_send_key<P: TLVBuilderParent>(
557563
&self,
558564
_ctx: impl InvokeContext,
559565
request: SendKeyRequest<'_>,

0 commit comments

Comments
 (0)