17
17
//! makes it possible to paginate forward or backward, from that event, until
18
18
//! one end of the timeline (front or back) is reached.
19
19
20
- use std:: sync:: Mutex ;
20
+ use std:: { future :: Future , sync:: Mutex } ;
21
21
22
22
use eyeball:: { SharedObservable , Subscriber } ;
23
23
use matrix_sdk_base:: { deserialized_responses:: TimelineEvent , SendOutsideWasm , SyncOutsideWasm } ;
@@ -431,37 +431,35 @@ impl<PR: PaginableRoom> Paginator<PR> {
431
431
///
432
432
/// Not [`crate::Room`] because we may want to paginate rooms we don't belong
433
433
/// to.
434
- #[ cfg_attr( target_arch = "wasm32" , async_trait:: async_trait( ?Send ) ) ]
435
- #[ cfg_attr( not( target_arch = "wasm32" ) , async_trait:: async_trait) ]
436
434
pub trait PaginableRoom : SendOutsideWasm + SyncOutsideWasm {
437
435
/// Runs a /context query for the given room.
438
436
///
439
437
/// ## Parameters
440
438
///
441
439
/// - `event_id` is the identifier of the target event.
442
440
/// - `lazy_load_members` controls whether room membership events are lazily
443
- /// loaded as context
444
- /// state events.
441
+ /// loaded as context state events.
445
442
/// - `num_events` is the number of events (including the fetched event) to
446
- /// return as context.
443
+ /// return as context.
447
444
///
448
445
/// ## Returns
449
446
///
450
447
/// Must return [`PaginatorError::EventNotFound`] whenever the target event
451
448
/// could not be found, instead of causing an http `Err` result.
452
- async fn event_with_context (
449
+ fn event_with_context (
453
450
& self ,
454
451
event_id : & EventId ,
455
452
lazy_load_members : bool ,
456
453
num_events : UInt ,
457
- ) -> Result < EventWithContextResponse , PaginatorError > ;
454
+ ) -> impl Future < Output = Result < EventWithContextResponse , PaginatorError > > + Send ;
458
455
459
456
/// Runs a /messages query for the given room.
460
- async fn messages ( & self , opts : MessagesOptions ) -> Result < Messages , PaginatorError > ;
457
+ fn messages (
458
+ & self ,
459
+ opts : MessagesOptions ,
460
+ ) -> impl Future < Output = Result < Messages , PaginatorError > > + Send ;
461
461
}
462
462
463
- #[ cfg_attr( target_arch = "wasm32" , async_trait:: async_trait( ?Send ) ) ]
464
- #[ cfg_attr( not( target_arch = "wasm32" ) , async_trait:: async_trait) ]
465
463
impl PaginableRoom for Room {
466
464
async fn event_with_context (
467
465
& self ,
@@ -474,8 +472,9 @@ impl PaginableRoom for Room {
474
472
Ok ( result) => result,
475
473
476
474
Err ( err) => {
477
- // If the error was a 404, then the event wasn't found on the server; special
478
- // case this to make it easy to react to such an error.
475
+ // If the error was a 404, then the event wasn't found on the server;
476
+ // special case this to make it easy to react to
477
+ // such an error.
479
478
if let Some ( error) = err. as_client_api_error ( ) {
480
479
if error. status_code == 404 {
481
480
// Event not found
@@ -496,8 +495,6 @@ impl PaginableRoom for Room {
496
495
}
497
496
}
498
497
499
- #[ cfg_attr( target_arch = "wasm32" , async_trait:: async_trait( ?Send ) ) ]
500
- #[ cfg_attr( not( target_arch = "wasm32" ) , async_trait:: async_trait) ]
501
498
impl PaginableRoom for WeakRoom {
502
499
async fn event_with_context (
503
500
& self ,
@@ -513,7 +510,6 @@ impl PaginableRoom for WeakRoom {
513
510
PaginableRoom :: event_with_context ( & room, event_id, lazy_load_members, num_events) . await
514
511
}
515
512
516
- /// Runs a /messages query for the given room.
517
513
async fn messages ( & self , opts : MessagesOptions ) -> Result < Messages , PaginatorError > {
518
514
let Some ( room) = self . get ( ) else {
519
515
// Client is shutting down, return a default response.
@@ -529,7 +525,6 @@ mod tests {
529
525
use std:: sync:: Arc ;
530
526
531
527
use assert_matches2:: assert_let;
532
- use async_trait:: async_trait;
533
528
use futures_core:: Future ;
534
529
use futures_util:: FutureExt as _;
535
530
use matrix_sdk_base:: deserialized_responses:: TimelineEvent ;
@@ -589,7 +584,6 @@ mod tests {
589
584
static ROOM_ID : Lazy < & RoomId > = Lazy :: new ( || room_id ! ( "!dune:herbert.org" ) ) ;
590
585
static USER_ID : Lazy < & UserId > = Lazy :: new ( || user_id ! ( "@paul:atreid.es" ) ) ;
591
586
592
- #[ async_trait]
593
587
impl PaginableRoom for TestRoom {
594
588
async fn event_with_context (
595
589
& self ,
@@ -1089,7 +1083,6 @@ mod tests {
1089
1083
}
1090
1084
}
1091
1085
1092
- #[ async_trait]
1093
1086
impl PaginableRoom for AbortingRoom {
1094
1087
async fn event_with_context (
1095
1088
& self ,
0 commit comments