Auto-generated Rust types for all Telegram API Layer 224 constructors, functions, and enums.
2,329 TL definitions generated at build time from Layer 224. All constructors, functions, and abstract types are represented as Rust structs and enums with binary TL serialization and deserialization.
[dependencies]
ferogram-tl-types = "0.3.0"
# With MTProto low-level types (required by ferogram-mtproto):
ferogram-tl-types = { version = "0.3.0", features = ["tl-mtproto"] }// TL constructors become structs
pub mod types {
pub struct Message {
pub id: i32,
pub peer_id: enums::Peer,
pub message: String,
// optional fields wrapped in Option<>
}
}
// Abstract TL types become enums
pub mod enums {
pub enum Message {
Message(types::Message),
Service(types::MessageService),
Empty(types::MessageEmpty),
}
}
// TL functions become structs implementing RemoteCall
pub mod functions {
pub mod messages {
pub struct SendMessage { /* fields */ }
impl RemoteCall for SendMessage {
type Return = enums::Updates;
}
}
}| Feature | Default | Description |
|---|---|---|
tl-api |
yes | Telegram API schema (api.tl) |
tl-mtproto |
no | MTProto internal schema (mtproto.tl) |
impl-debug |
yes | #[derive(Debug)] on all types |
impl-from-type |
yes | From<types::T> for enums::E |
impl-from-enum |
yes | TryFrom<enums::E> for types::T |
deserializable-functions |
no | Deserializable on function types |
name-for-id |
no | name_for_id(u32) -> Option<&'static str> |
impl-serde |
no | serde::Serialize / Deserialize |
cp new-api.tl ferogram-tl-types/tl/api.tl
cargo buildferogram-tl-gen regenerates all types at compile time via build.rs. No manual code changes needed.
ferogram
└ ferogram-mtproto
└ ferogram-tl-types <-- here
└ (build) ferogram-tl-gen
└ (build) ferogram-tl-parser
MIT or Apache-2.0, at your option. See LICENSE-MIT and LICENSE-APACHE.
Ankit Chaubey - github.com/ankit-chaubey