layer-tl-gen
Build-time Rust code generator for Telegram's TL schema.
Build-dependency only. Runs during cargo build via build.rs and produces Rust source code from a parsed TL AST.
Installation
[]
= "0.4.7"
Usage in build.rs
use ;
In lib.rs:
include!;
Config
| Field | Description |
|---|---|
impl_debug |
#[derive(Debug)] on all types |
impl_from_type |
From<types::T> for enums::E |
impl_from_enum |
TryFrom<enums::E> for types::T |
impl_serde |
serde::Serialize / Deserialize |
name_for_id |
name_for_id(u32) -> Option<&'static str> CRC32 lookup |
Generated Output
For each TL constructor, generates a Rust struct with Serializable / Deserializable impls. For each abstract type, generates a Rust enum with discriminated deserialization on the 4-byte CRC32 ID. For each function, generates a struct implementing RemoteCall with the correct return type.
Module layout:
generated.rs
├ mod types one struct per TL constructor
├ mod enums one enum per TL abstract type
└ mod functions
├ mod account
├ mod auth
├ mod channels
├ mod messages
└ ...
Stack position
layer-tl-types (consumes generated code)
└ layer-tl-gen <-- here
└ layer-tl-parser
License
MIT or Apache-2.0, at your option. See LICENSE-MIT and LICENSE-APACHE.
Ankit Chaubey - github.com/ankit-chaubey