@@ -10,8 +10,9 @@ use ruma::{
10
10
tag:: { create_tag, delete_tag} ,
11
11
} ,
12
12
events:: {
13
- room:: history_visibility:: HistoryVisibility , tag:: TagInfo , AnyStateEvent ,
14
- AnySyncStateEvent , EventType ,
13
+ room:: history_visibility:: HistoryVisibility ,
14
+ tag:: { TagInfo , TagName } ,
15
+ AnyStateEvent , AnySyncStateEvent , EventType ,
15
16
} ,
16
17
serde:: Raw ,
17
18
EventId , UserId ,
@@ -460,7 +461,8 @@ impl Common {
460
461
/// # Example
461
462
///
462
463
/// ```no_run
463
- /// # use ruma::events::tag::TagInfo;
464
+ /// # use std::str::FromStr;
465
+ /// # use ruma::events::tag::{TagInfo, TagName, UserTagName};
464
466
/// # futures::executor::block_on(async {
465
467
/// # let homeserver = url::Url::parse("http://localhost:8080")?;
466
468
/// # let mut client = matrix_sdk::Client::new(homeserver)?;
@@ -470,14 +472,20 @@ impl Common {
470
472
/// if let Some(room) = client.get_joined_room(&room_id) {
471
473
/// let mut tag_info = TagInfo::new();
472
474
/// tag_info.order = Some(0.9);
475
+ /// let user_tag = UserTagName::from_str("u.work")?;
473
476
///
474
- /// room.set_tag("u.work" , tag_info ).await?;
477
+ /// room.set_tag(TagName::User(user_tag) , tag_info ).await?;
475
478
/// }
476
479
/// # Result::<_, matrix_sdk::Error>::Ok(()) });
477
480
/// ```
478
- pub async fn set_tag ( & self , tag : & str , tag_info : TagInfo ) -> HttpResult < create_tag:: Response > {
481
+ pub async fn set_tag (
482
+ & self ,
483
+ tag : TagName ,
484
+ tag_info : TagInfo ,
485
+ ) -> HttpResult < create_tag:: Response > {
479
486
let user_id = self . client . user_id ( ) . await . ok_or ( HttpError :: AuthenticationRequired ) ?;
480
- let request = create_tag:: Request :: new ( & user_id, self . inner . room_id ( ) , tag, tag_info) ;
487
+ let request =
488
+ create_tag:: Request :: new ( & user_id, self . inner . room_id ( ) , tag. as_ref ( ) , tag_info) ;
481
489
self . client . send ( request, None ) . await
482
490
}
483
491
@@ -487,9 +495,9 @@ impl Common {
487
495
///
488
496
/// # Arguments
489
497
/// * `tag` - The tag to remove.
490
- pub async fn remove_tag ( & self , tag : & str ) -> HttpResult < delete_tag:: Response > {
498
+ pub async fn remove_tag ( & self , tag : TagName ) -> HttpResult < delete_tag:: Response > {
491
499
let user_id = self . client . user_id ( ) . await . ok_or ( HttpError :: AuthenticationRequired ) ?;
492
- let request = delete_tag:: Request :: new ( & user_id, self . inner . room_id ( ) , tag) ;
500
+ let request = delete_tag:: Request :: new ( & user_id, self . inner . room_id ( ) , tag. as_ref ( ) ) ;
493
501
self . client . send ( request, None ) . await
494
502
}
495
503
}
0 commit comments