Skip to main content

Crate ferogram_tl_parser

Crate ferogram_tl_parser 

Source
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.

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:

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.