16
16
17
17
#![ deny( unreachable_pub) ]
18
18
19
- use std:: future:: IntoFuture ;
19
+ use std:: { borrow :: Borrow , future:: IntoFuture } ;
20
20
21
21
use eyeball:: SharedObservable ;
22
22
use matrix_sdk_common:: boxed_into_future;
@@ -26,7 +26,10 @@ use ruma::events::{MessageLikeUnsigned, SyncMessageLikeEvent};
26
26
use ruma:: {
27
27
api:: client:: { message:: send_message_event, state:: send_state_event} ,
28
28
assign,
29
- events:: { AnyMessageLikeEventContent , AnyStateEventContent , MessageLikeEventContent } ,
29
+ events:: {
30
+ AnyMessageLikeEventContent , AnyStateEventContent , MessageLikeEventContent ,
31
+ StateEventContent ,
32
+ } ,
30
33
serde:: Raw ,
31
34
OwnedTransactionId , TransactionId ,
32
35
} ;
@@ -322,6 +325,37 @@ impl<'a> IntoFuture for SendAttachment<'a> {
322
325
}
323
326
}
324
327
328
+ /// TODO: Future returned by `Room::send_state_event`.
329
+ #[ allow( missing_debug_implementations) ]
330
+ pub struct SendStateEvent < ' a > {
331
+ room : & ' a Room ,
332
+ event_type : String ,
333
+ state_key : String ,
334
+ content : serde_json:: Result < serde_json:: Value > ,
335
+ request_config : Option < RequestConfig > ,
336
+ }
337
+
338
+ impl < ' a > SendStateEvent < ' a > {
339
+ pub ( crate ) fn new < C , K > ( room : & ' a Room , state_key : & K , content : C ) -> Self
340
+ where
341
+ C : StateEventContent ,
342
+ C :: StateKey : Borrow < K > ,
343
+ K : AsRef < str > + ?Sized ,
344
+ {
345
+ let event_type = content. event_type ( ) . to_string ( ) ;
346
+ let state_key = state_key. as_ref ( ) . to_owned ( ) ;
347
+ let content = serde_json:: to_value ( & content) ;
348
+ Self { room, event_type, state_key, content, request_config : None }
349
+ }
350
+
351
+ /// Assign a given [`RequestConfig`] to configure how this request should
352
+ /// behave with respect to the network.
353
+ pub fn with_request_config ( mut self , request_config : RequestConfig ) -> Self {
354
+ self . request_config = Some ( request_config) ;
355
+ self
356
+ }
357
+ }
358
+
325
359
/// Future returned by [`Room::send_state_event_raw`].
326
360
#[ allow( missing_debug_implementations) ]
327
361
pub struct SendStateEventRaw < ' a > {
0 commit comments