Expand description
Parser for Telegram’s Type Language (TL) schema files.
This crate is part of ferogram, an async Rust MTProto client built by Ankit Chaubey.
- Channel: t.me/Ferogram
- Chat: t.me/FerogramChat
Converts raw .tl schema text into a tl::Definition AST. That AST is
then consumed by ferogram-tl-gen to produce the Rust type bindings in
ferogram-tl-types.
Most users never touch this crate. It matters when you are upgrading the TL layer, writing a custom code generator, or doing schema introspection.
§Usage
use ferogram_tl_parser::parse_tl_file;
let src = "user#12345678 id:long name:string = User;";
for def in parse_tl_file(src) {
let def = def.unwrap();
println!("{} #{:08x}", def.name, def.id);
}parse_tl_file returns an iterator of Result<Definition, ParseError>.
It handles both constructor and function sections of a .tl file.
§AST
The main types are in the tl module:
tl::Definition: one parsed TL declaration (constructor or function).tl::Parameter: a field name and type.tl::Type: a TL type reference (with optional generic argument).
Modules§
- errors
- Parse error types for TL schema parsing.
- tl
- Core TL schema types: definitions, parameters, types, flags, and categories.
Functions§
- parse_
tl_ file - Parses a complete TL schema file, yielding
Definitions one by one.