Skip to content

Commit 7d7bd97

Browse files
committed
Document how to create a Session
1 parent f5ba9a5 commit 7d7bd97

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

crates/matrix-sdk-base/src/session.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ use serde::{Deserialize, Serialize};
2020

2121
/// A user session, containing an access token and information about the
2222
/// associated user account.
23+
///
24+
/// # Example
25+
///
26+
/// ```
27+
/// use matrix_sdk_base::Session;
28+
/// use ruma::UserId;
29+
/// use std::str::FromStr;
30+
///
31+
/// let session = Session {
32+
/// access_token: String::from("abcdefgh012345678"),
33+
/// user_id: UserId::from_str("@name:example.com").unwrap(),
34+
/// device_id: "zyxwv54321".into(),
35+
/// };
36+
///
37+
/// assert_eq!(session.device_id.as_str(), "zyxwv54321");
38+
/// ```
2339
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
2440
pub struct Session {
2541
/// The access token used for this session.

0 commit comments

Comments
 (0)