1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use std::ops::Deref;
use ruma::api::client::r0::membership::forget_room;
use crate::{room::Common, BaseRoom, Client, Result, RoomType};
#[derive(Debug, Clone)]
pub struct Left {
pub(crate) inner: Common,
}
impl Left {
pub fn new(client: Client, room: BaseRoom) -> Option<Self> {
if room.room_type() == RoomType::Left {
Some(Self { inner: Common::new(client, room) })
} else {
None
}
}
pub async fn join(&self) -> Result<()> {
self.inner.join().await
}
pub async fn forget(&self) -> Result<()> {
let request = forget_room::Request::new(self.inner.room_id());
let _response = self.client.send(request, None).await?;
Ok(())
}
}
impl Deref for Left {
type Target = Common;
fn deref(&self) -> &Self::Target {
&self.inner
}
}