pub struct PersistedSession {
pub home_dc_id: i32,
pub dcs: Vec<DcEntry>,
pub updates_state: UpdatesStateSnap,
pub peers: Vec<CachedPeer>,
pub min_peers: Vec<CachedMinPeer>,
}Expand description
Everything that needs to survive a process restart.
Fields§
§home_dc_id: i32§dcs: Vec<DcEntry>§updates_state: UpdatesStateSnapUpdate counters to enable reliable catch-up after a disconnect.
peers: Vec<CachedPeer>Peer access-hash cache so that the client can reach out to any previously seen user or channel without re-resolving them.
min_peers: Vec<CachedMinPeer>Min-user message contexts: users seen with min=true that can only be
addressed via InputPeerUserFromMessage.
Implementations§
Source§impl PersistedSession
impl PersistedSession
Sourcepub fn save(&self, path: &Path) -> Result<()>
pub fn save(&self, path: &Path) -> Result<()>
Atomically save the session to path.
Writes to <path>.tmp first, then renames into place so a crash
mid-write never corrupts the existing session file.
Sourcepub fn from_bytes(buf: &[u8]) -> Result<Self>
pub fn from_bytes(buf: &[u8]) -> Result<Self>
Decode a session from raw bytes (v1 or v2 binary format).
Sourcepub fn from_string(s: &str) -> Result<Self>
pub fn from_string(s: &str) -> Result<Self>
Decode a session from a URL-safe base64 string produced by [to_string].
pub fn load(path: &Path) -> Result<Self>
Sourcepub fn dc_for(&self, dc_id: i32, prefer_ipv6: bool) -> Option<&DcEntry>
pub fn dc_for(&self, dc_id: i32, prefer_ipv6: bool) -> Option<&DcEntry>
Find the best DC entry for a given DC ID.
When prefer_ipv6 is true, returns the IPv6 entry if one is
stored, falling back to IPv4. When false, returns IPv4,
falling back to IPv6. Returns None only when the DC ID is
completely unknown.
This correctly handles the case where both an IPv4 and an IPv6
DcEntry exist for the same dc_id (different flags bitmask).
Sourcepub fn all_dcs_for(&self, dc_id: i32) -> impl Iterator<Item = &DcEntry>
pub fn all_dcs_for(&self, dc_id: i32) -> impl Iterator<Item = &DcEntry>
Iterate over every stored DC entry for a given DC ID.
Typically yields one IPv4 and one IPv6 entry per DC ID once
help.getConfig has been applied.
Trait Implementations§
Source§impl Clone for PersistedSession
impl Clone for PersistedSession
Source§fn clone(&self) -> PersistedSession
fn clone(&self) -> PersistedSession
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more