tl-proto

A collection of traits for working with TL serialization/deserialization.
Example
/* my_proto.tl */
int ? = Int;
string ? = String;
bytes data:string = Bytes;
int256 8*[ int ] = Int256;
pub.ed25519 key:int256 = PublicKey;
pub.aes key:int256 = PublicKey;
pub.overlay name:bytes = PublicKey;
NOTE: TL scheme is parsed by
tl-schemecrate at compile time.
use ;
;
Specification
| Type | Pseudocode |
|---|---|
() |
[] |
i32,u32,i64,u64 |
little_endian(x) |
true |
[0xb5, 0x75, 0x72, 0x99] |
false |
[0x37, 0x97, 0x79, 0xbc] |
[u8; N], N % 4 ≡ 0) |
[…x] |
Vec<u8>, len < 254) |
[len as u8, …x, …padding_to_4(len)] |
Vec<u8>, len ≥ 254) |
[254, …little_endian(x)[0..=2], …x, …padding_to_4(len)] |
Vec<T> |
[…little_endian(len as u32), …map(…x, repr)] |
(T0, … , Tn) |
[…repr(T0), … , …repr(Tn)] |
Option<T> |
{ Some(x) ⇒ repr(x), None ⇒ [] } |
enum { T0, …, Tn } |
{ T0(x) ⇒ […id(T0), …repr(x)], …, Tn(x) ⇒ […id(Tn), …repr(x)] } |