/
oms
/
lib
Обзор
Документация
Войти
/
oms
/
lib
Код
Запросы
0
Задачи
Пакеты
0
Релизы
0
Аналитика
master
src/types/profile.rs
33 строки
1 KB
dot
attempt to get token expiry date from base64 in the token
16 сен 2024, 10:19
16 сен 2024, 10:19
2ddef1e
Код
Авторство
О чём код?
//! Type used for profile information. //! //! `Profile` struct provides [`mesh_id`](Profile::mesh_id) and [`user_id`](Profile::user_id) use chrono::{DateTime, Utc}; use serde::{Serialize, Deserialize}; /// Profile used for requesting information from the server. #[derive(Clone, Serialize, Deserialize)] pub struct Profile { /// Mesh ID provided by the server. pub mesh_id: String, /// User ID provided by the server. pub user_id: i64, /// Expiry date for the token. pub token_expires: DateTime<Utc> } impl Profile { /// Creates a Profile with provided Mesh ID and User ID. /// /// Usage of `get_profile()` is recommended instead of manual creation. pub fn new(mesh_id: String, user_id: i64, token_expires: DateTime<Utc>) -> Profile { return Profile { mesh_id, user_id, token_expires }; } /// Serializes the Profile into a JSON string. /// /// Wrapper for `serde_json::to_string()` pub fn serialize(self) -> String { serde_json::to_string(&self).unwrap() } }