From 7d7bd97812a5b203e2525985df714f95eb334ae7 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Thu, 18 Nov 2021 14:18:16 +0000 Subject: [PATCH] Document how to create a Session --- crates/matrix-sdk-base/src/session.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/matrix-sdk-base/src/session.rs b/crates/matrix-sdk-base/src/session.rs index c162cecd0..fe0fac960 100644 --- a/crates/matrix-sdk-base/src/session.rs +++ b/crates/matrix-sdk-base/src/session.rs @@ -20,6 +20,22 @@ use serde::{Deserialize, Serialize}; /// A user session, containing an access token and information about the /// associated user account. +/// +/// # Example +/// +/// ``` +/// use matrix_sdk_base::Session; +/// use ruma::UserId; +/// use std::str::FromStr; +/// +/// let session = Session { +/// access_token: String::from("abcdefgh012345678"), +/// user_id: UserId::from_str("@name:example.com").unwrap(), +/// device_id: "zyxwv54321".into(), +/// }; +/// +/// assert_eq!(session.device_id.as_str(), "zyxwv54321"); +/// ``` #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct Session { /// The access token used for this session.