1616
1717use std:: {
1818 collections:: { BTreeMap , HashMap } ,
19- future:: ready,
2019 ops:: Sub ,
2120 sync:: Arc ,
2221 time:: { Duration , SystemTime } ,
@@ -25,7 +24,6 @@ use std::{
2524use eyeball:: { SharedObservable , Subscriber } ;
2625use eyeball_im:: VectorDiff ;
2726use futures_core:: Stream ;
28- use futures_util:: FutureExt as _;
2927use indexmap:: IndexMap ;
3028use matrix_sdk:: {
3129 config:: RequestConfig ,
@@ -380,56 +378,51 @@ impl RoomDataProvider for TestRoomDataProvider {
380378 RoomVersionId :: V10
381379 }
382380
383- fn crypto_context_info ( & self ) -> BoxFuture < ' _ , CryptoContextInfo > {
384- ready ( CryptoContextInfo {
381+ async fn crypto_context_info ( & self ) -> CryptoContextInfo {
382+ CryptoContextInfo {
385383 device_creation_ts : MilliSecondsSinceUnixEpoch :: from_system_time (
386384 SystemTime :: now ( ) . sub ( Duration :: from_secs ( 60 * 3 ) ) ,
387385 )
388386 . unwrap_or ( MilliSecondsSinceUnixEpoch :: now ( ) ) ,
389387 is_backup_configured : false ,
390388 this_device_is_verified : true ,
391389 backup_exists_on_server : true ,
392- } )
393- . boxed ( )
390+ }
394391 }
395392
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
398395 }
399396
400397 fn profile_from_latest_event ( & self , _latest_event : & LatestEvent ) -> Option < Profile > {
401398 None
402399 }
403400
404- fn load_user_receipt (
405- & self ,
401+ async fn load_user_receipt < ' a > (
402+ & ' a self ,
406403 receipt_type : ReceiptType ,
407404 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" ) {
425419 [ ( BOB . to_owned ( ) , Receipt :: new ( MilliSecondsSinceUnixEpoch ( uint ! ( 10 ) ) ) ) ] . into ( )
426420 } else {
427421 IndexMap :: new ( )
428- } )
429- . boxed ( )
422+ }
430423 }
431424
432- fn push_rules_and_context ( & self ) -> BoxFuture < ' _ , Option < ( Ruleset , PushConditionRoomCtx ) > > {
425+ async fn push_rules_and_context ( & self ) -> Option < ( Ruleset , PushConditionRoomCtx ) > {
433426 let push_rules = Ruleset :: server_default ( & ALICE ) ;
434427 let power_levels = PushConditionPowerLevelsCtx {
435428 users : BTreeMap :: new ( ) ,
@@ -444,32 +437,26 @@ impl RoomDataProvider for TestRoomDataProvider {
444437 power_levels : Some ( power_levels) ,
445438 } ;
446439
447- ready ( Some ( ( push_rules, push_context) ) ) . boxed ( )
440+ Some ( ( push_rules, push_context) )
448441 }
449442
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 ( )
452445 }
453446
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 ( ( ) )
460450 }
461451
462- fn redact < ' a > (
452+ async fn redact < ' a > (
463453 & ' a self ,
464454 event_id : & ' a EventId ,
465455 _reason : Option < & ' a str > ,
466456 _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 ( ( ) )
473460 }
474461
475462 fn room_info ( & self ) -> Subscriber < RoomInfo > {
0 commit comments