⚡ layer
layer is a hand-written, bottom-up implementation of Telegram MTProto in pure Rust. Every component — from the .tl schema parser, to AES-IGE encryption, to the Diffie-Hellman key exchange, to the typed async update stream — is owned and understood by this project.
No black boxes. No magic. Just Rust, all the way down.
Why layer?
Most Telegram libraries are thin wrappers around generated code or ports from Python/JavaScript. layer is different — it was built from scratch to understand MTProto at the lowest level, then wrapped in an ergonomic high-level API.
client.invoke() with full type safety.Crate overview
| Crate | Description | Typical user |
|---|---|---|
layer-client | High-level async client — auth, send, receive, bots | ✅ You |
layer-tl-types | All Layer 223 constructors, functions, enums | Raw API calls |
layer-mtproto | MTProto session, DH, framing, transport | Library authors |
layer-crypto | AES-IGE, RSA, SHA, auth key derivation | Internal |
layer-tl-gen | Build-time Rust code generator | Build tool |
layer-tl-parser | .tl schema → AST parser | Build tool |
TIP: Most users only ever import
layer-client. The other crates are either used internally or for advanced raw API calls.
Quick install
[dependencies]
layer-client = "0.2.2"
tokio = { version = "1", features = ["full"] }
Then head to Installation for credentials setup, or jump straight to:
- Quick Start — User Account — login, send a message, receive updates
- Quick Start — Bot — bot token login, commands, callbacks