pub struct MapData {
pub version: u32,
pub legacy_salt: Option<Vec<u8>>,
pub legacy_key_encrypted: Option<Vec<u8>>,
pub entries: Vec<MapEntry>,
pub stopped_at: Option<u32>,
}Expand description
A decoded maps file.
Fields§
§version: u32Telegram Desktop version stored in the TDF$ header.
legacy_salt: Option<Vec<u8>>The legacy salt; None for a null array.
legacy_key_encrypted: Option<Vec<u8>>The legacy local key wrap; None for a null array.
entries: Vec<MapEntry>The decoded entries in file order.
stopped_at: Option<u32>The unknown key type the entries stopped at, if any; everything after it is ignored.
Implementations§
Source§impl MapData
impl MapData
Sourcepub fn parse_entries(data: &[u8]) -> Result<(Vec<MapEntry>, Option<u32>)>
pub fn parse_entries(data: &[u8]) -> Result<(Vec<MapEntry>, Option<u32>)>
Decodes a decrypted map (the data part of the encrypted blob) into its entries and the unknown key type they stopped at.
A key type that cannot be read in full ends the entries like an
unknown one, since a short value reads as 0 (lskUserMap).
§Errors
Error::QDataStreamFailed when an entry of a known type is cut
short or holds an invalid string.
Sourcepub fn read(dir: impl AsRef<Path>, local_key: &AuthKey) -> Result<Self>
pub fn read(dir: impl AsRef<Path>, local_key: &AuthKey) -> Result<Self>
Reads and decrypts the maps file in the account folder dir
(MapData.read with a local key).
§Errors
Error::ReadMapDataFailedwhen the file is missing or invalid, or the map does not decrypt underlocal_key.Error::QDataStreamFailedwhen the three arrays or an entry are cut short.
Sourcepub fn new_account() -> Self
pub fn new_account() -> Self
The map of a new account: only the
NEW_ACCOUNT_SETTINGS_KEY user settings key, APP_VERSION, and
no legacy arrays.
Sourcepub fn encode_entries(&self) -> Result<Vec<u8>>
pub fn encode_entries(&self) -> Result<Vec<u8>>
Encodes the decrypted map, which is not a copy of the entries: they are first folded into one field per file key slot.
- File keys land in their named slots, a later entry overwriting an
earlier one;
lskStickersOldfills the installed stickers key andlskBackgroundOldOldthe day background key. The three old skip types and the two legacy wallet keys are dropped, and so are legacy locations. - Draft, draft cursor, and bot storage pairs are keyed by peer id
(
PeerId.FromSerialized, legacy layouts converted); a repeated peer keeps its first position and its last file key. Peers are written with the serialized-id flag set (PeerId.Serialize). - The self user, the web view tokens, and the wallet engine storages keep the last entry; wallet entries are written sorted by name, a null name as an empty one.
The output follows a fixed type order and writes a key type only when one of its keys is non-zero, the self user only when it is non-empty, the web view tokens only when one is non-empty, and the wallet engine storages only when there is one.
§Errors
Error::QDataStreamFailed when a count or blob does not fit a u32.
Trait Implementations§
impl Eq for MapData
impl StructuralPartialEq for MapData
Auto Trait Implementations§
impl Freeze for MapData
impl RefUnwindSafe for MapData
impl Send for MapData
impl Sync for MapData
impl Unpin for MapData
impl UnsafeUnpin for MapData
impl UnwindSafe for MapData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more