16
16
17
17
use std:: {
18
18
collections:: { BTreeMap , HashMap } ,
19
- future:: ready,
20
19
ops:: Sub ,
21
20
sync:: Arc ,
22
21
time:: { Duration , SystemTime } ,
@@ -25,7 +24,6 @@ use std::{
25
24
use eyeball:: { SharedObservable , Subscriber } ;
26
25
use eyeball_im:: VectorDiff ;
27
26
use futures_core:: Stream ;
28
- use futures_util:: FutureExt as _;
29
27
use indexmap:: IndexMap ;
30
28
use matrix_sdk:: {
31
29
config:: RequestConfig ,
@@ -380,56 +378,51 @@ impl RoomDataProvider for TestRoomDataProvider {
380
378
RoomVersionId :: V10
381
379
}
382
380
383
- fn crypto_context_info ( & self ) -> BoxFuture < ' _ , CryptoContextInfo > {
384
- ready ( CryptoContextInfo {
381
+ async fn crypto_context_info ( & self ) -> CryptoContextInfo {
382
+ CryptoContextInfo {
385
383
device_creation_ts : MilliSecondsSinceUnixEpoch :: from_system_time (
386
384
SystemTime :: now ( ) . sub ( Duration :: from_secs ( 60 * 3 ) ) ,
387
385
)
388
386
. unwrap_or ( MilliSecondsSinceUnixEpoch :: now ( ) ) ,
389
387
is_backup_configured : false ,
390
388
this_device_is_verified : true ,
391
389
backup_exists_on_server : true ,
392
- } )
393
- . boxed ( )
390
+ }
394
391
}
395
392
396
- fn profile_from_user_id < ' a > ( & ' a self , _user_id : & ' a UserId ) -> BoxFuture < ' a , Option < Profile > > {
397
- ready ( None ) . boxed ( )
393
+ async fn profile_from_user_id < ' a > ( & ' a self , _user_id : & ' a UserId ) -> Option < Profile > {
394
+ None
398
395
}
399
396
400
397
fn profile_from_latest_event ( & self , _latest_event : & LatestEvent ) -> Option < Profile > {
401
398
None
402
399
}
403
400
404
- fn load_user_receipt (
405
- & self ,
401
+ async fn load_user_receipt < ' a > (
402
+ & ' a self ,
406
403
receipt_type : ReceiptType ,
407
404
thread : ReceiptThread ,
408
- user_id : & UserId ,
409
- ) -> BoxFuture < ' _ , Option < ( OwnedEventId , Receipt ) > > {
410
- ready (
411
- self . initial_user_receipts
412
- . get ( & receipt_type)
413
- . and_then ( |thread_map| thread_map. get ( & thread) )
414
- . and_then ( |user_map| user_map. get ( user_id) )
415
- . cloned ( ) ,
416
- )
417
- . boxed ( )
418
- }
419
-
420
- fn load_event_receipts (
421
- & self ,
422
- event_id : & EventId ,
423
- ) -> BoxFuture < ' _ , IndexMap < OwnedUserId , Receipt > > {
424
- ready ( if event_id == event_id ! ( "$event_with_bob_receipt" ) {
405
+ user_id : & ' a UserId ,
406
+ ) -> Option < ( OwnedEventId , Receipt ) > {
407
+ self . initial_user_receipts
408
+ . get ( & receipt_type)
409
+ . and_then ( |thread_map| thread_map. get ( & thread) )
410
+ . and_then ( |user_map| user_map. get ( user_id) )
411
+ . cloned ( )
412
+ }
413
+
414
+ async fn load_event_receipts < ' a > (
415
+ & ' a self ,
416
+ event_id : & ' a EventId ,
417
+ ) -> IndexMap < OwnedUserId , Receipt > {
418
+ if event_id == event_id ! ( "$event_with_bob_receipt" ) {
425
419
[ ( BOB . to_owned ( ) , Receipt :: new ( MilliSecondsSinceUnixEpoch ( uint ! ( 10 ) ) ) ) ] . into ( )
426
420
} else {
427
421
IndexMap :: new ( )
428
- } )
429
- . boxed ( )
422
+ }
430
423
}
431
424
432
- fn push_rules_and_context ( & self ) -> BoxFuture < ' _ , Option < ( Ruleset , PushConditionRoomCtx ) > > {
425
+ async fn push_rules_and_context ( & self ) -> Option < ( Ruleset , PushConditionRoomCtx ) > {
433
426
let push_rules = Ruleset :: server_default ( & ALICE ) ;
434
427
let power_levels = PushConditionPowerLevelsCtx {
435
428
users : BTreeMap :: new ( ) ,
@@ -444,32 +437,26 @@ impl RoomDataProvider for TestRoomDataProvider {
444
437
power_levels : Some ( power_levels) ,
445
438
} ;
446
439
447
- ready ( Some ( ( push_rules, push_context) ) ) . boxed ( )
440
+ Some ( ( push_rules, push_context) )
448
441
}
449
442
450
- fn load_fully_read_marker ( & self ) -> BoxFuture < ' _ , Option < OwnedEventId > > {
451
- ready ( self . fully_read_marker . clone ( ) ) . boxed ( )
443
+ async fn load_fully_read_marker ( & self ) -> Option < OwnedEventId > {
444
+ self . fully_read_marker . clone ( )
452
445
}
453
446
454
- fn send ( & self , content : AnyMessageLikeEventContent ) -> BoxFuture < ' _ , Result < ( ) , super :: Error > > {
455
- async move {
456
- self . sent_events . write ( ) . await . push ( content) ;
457
- Ok ( ( ) )
458
- }
459
- . boxed ( )
447
+ async fn send ( & self , content : AnyMessageLikeEventContent ) -> Result < ( ) , super :: Error > {
448
+ self . sent_events . write ( ) . await . push ( content) ;
449
+ Ok ( ( ) )
460
450
}
461
451
462
- fn redact < ' a > (
452
+ async fn redact < ' a > (
463
453
& ' a self ,
464
454
event_id : & ' a EventId ,
465
455
_reason : Option < & ' a str > ,
466
456
_transaction_id : Option < OwnedTransactionId > ,
467
- ) -> BoxFuture < ' a , Result < ( ) , super :: Error > > {
468
- async move {
469
- self . redacted . write ( ) . await . push ( event_id. to_owned ( ) ) ;
470
- Ok ( ( ) )
471
- }
472
- . boxed ( )
457
+ ) -> Result < ( ) , super :: Error > {
458
+ self . redacted . write ( ) . await . push ( event_id. to_owned ( ) ) ;
459
+ Ok ( ( ) )
473
460
}
474
461
475
462
fn room_info ( & self ) -> Subscriber < RoomInfo > {
0 commit comments