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
57
use ruma_identifiers::UserId;
#[derive(Clone, Debug, serde::Deserialize, Eq, Hash, PartialEq, serde::Serialize)]
pub struct Session {
pub access_token: String,
pub identification: Option<Identification>,
}
#[derive(Clone, Debug, serde::Deserialize, Eq, Hash, PartialEq, serde::Serialize)]
pub struct Identification {
pub user_id: UserId,
pub device_id: String,
}
impl Session {
#[deprecated]
pub fn new(access_token: String, user_id: UserId, device_id: String) -> Self {
Self {
access_token,
identification: Some(Identification { user_id, device_id }),
}
}
#[deprecated]
pub fn access_token(&self) -> &str {
&self.access_token
}
#[deprecated]
pub fn user_id(&self) -> Option<&UserId> {
if let Some(identification) = &self.identification {
return Some(&identification.user_id);
}
None
}
#[deprecated]
pub fn device_id(&self) -> Option<&str> {
if let Some(identification) = &self.identification {
return Some(&identification.device_id);
}
None
}
}