Skip to main content

grammers_session/
lib.rs

1// Copyright 2020 - developers of the `grammers` project.
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9//! This library serves as the session interface for all of the crucial
10//! data that other Telegram libraries would need to operate correctly, including:
11//! - Datacenter addresses, to know where to connect.
12//! - Permanent Authorization Keys bound to each datacenter.
13//! - Update state, in order to catch up on missed updates while offline.
14//! - Cached peers, necessary to interact with the API.
15//!
16//! Most of the data is bound to the specific session, and cannot be reused
17//! outside of it. The exceptions are datacenter addresses, and update state
18//! which is actually account-bound.
19//!
20//! To use with other libraries, you will want to instantiate one of the
21//! [`storages`], which are what implement the [`Session`] trait.
22//!
23//! To convert between storages, you can use the [`SessionData`] as an
24//! intermediate step, and use its `From` implementations in combination
25//! with [`SessionData::import_to`]. Note that the `From` implementation
26//! will not copy all of the data, only that which is necessary.
27
28#![deny(unsafe_code)]
29
30mod dc_options;
31mod message_box;
32mod peer;
33mod session;
34mod session_data;
35pub mod storages;
36pub mod types;
37pub mod updates;
38
39pub(crate) use dc_options::{DEFAULT_DC, KNOWN_DC_OPTIONS};
40pub use session::Session;
41pub use session_data::SessionData;