Expand description
§layer — Telegram MTProto library
layer is a modular Rust library for the Telegram MTProto protocol.
It consists of four focused sub-crates wired together here for convenience:
| Sub-crate | Role |
|---|---|
layer-tl-parser | Parse .tl schema files into an AST |
layer-tl-gen | Generate Rust source from the AST (build-time) |
layer-tl-types | Auto-generated types, functions & enums |
layer-mtproto | Session state, message framing, transport traits |
§Quick start: raw API
use layer::tl::{functions, Serializable, RemoteCall};
use layer::mtproto::{Session, transport::AbridgedTransport};
// Build a raw TL request
let req = functions::help::GetConfig {};
let bytes = req.to_bytes();
// Pack it into an MTProto message
let mut session = Session::new();
let msg = session.pack(&req);
let wire = msg.to_plaintext_bytes();
// Send over your transport…§Updating the API layer
Replace layer-tl-types/tl/api.tl with the new schema and run cargo build.
Everything else regenerates automatically.
Re-exports§
pub use layer_tl_types as tl;pub use layer_mtproto as mtproto;pub use layer_crypto as crypto;
Modules§
- authentication
- Sans-IO MTProto authorization key generation.
Structs§
- AuthKey
- A Telegram authorization key (256 bytes) plus pre-computed identifiers.
- Encrypted
Session - MTProto 2.0 encrypted session state.
- Finished
- The final output of a successful auth key handshake.
- Session
- Tracks per-connection MTProto session state.
Constants§
- LAYER
- The API layer this code was generated from.
Traits§
- Deserializable
- Deserialize a value from TL binary format.
- Identifiable
- Every generated type has a unique 32-bit constructor ID.
- Remote
Call - Marks a function type that can be sent to Telegram as an RPC call.
- Serializable
- Serialize
selfinto TL binary format.