8 releases (breaking)

0.7.0 Sep 17, 2024
0.6.0 May 3, 2024
0.5.1 Nov 18, 2023
0.4.0 Oct 14, 2022
0.1.0 Jan 31, 2020

#340 in Encoding

Download history 99/week @ 2024-08-16 122/week @ 2024-08-23 69/week @ 2024-08-30 94/week @ 2024-09-06 207/week @ 2024-09-13 191/week @ 2024-09-20 166/week @ 2024-09-27 85/week @ 2024-10-04 195/week @ 2024-10-11 142/week @ 2024-10-18 153/week @ 2024-10-25 221/week @ 2024-11-01 275/week @ 2024-11-08 485/week @ 2024-11-15 240/week @ 2024-11-22 134/week @ 2024-11-29

1,162 downloads per month
Used in 8 crates (6 directly)

MIT/Apache

74KB
579 lines

grammers-tl-types

This library provides Rust struct and enum types representing the definitions from the Type Language build-time input files.

In addition, each type has an impl on Serializable and Deserializable, the former serializes instances into byte arrays as described by the section on Binary Data Serialization, and the latter deserializes them.


lib.rs:

This library contains the Rust definitions for Telegram's types and functions in the form of struct and enum. All of them implement Serializable, and by default only types implement Deserializable.

If you're here because you want to invoke the "raw API" methods Telegram has to offer, use the search or read through the available functions to find out what "parameters" such remote call needs. Then, create an instance of it and pass it to some higher level library that can talk with Telegram's servers.

To preserve compatibility with older applications, the API has a concept of "layers", where new layers can change, remove or add new definitions. The LAYER constant indicates which of the many layers was used to generate the definitions present in this version of this crate.

Usage

The primary purpose is using these definitions to create requests (known as functions) which can be serialized and sent to Telegram. Note that this crate has no way to "invoke" any of these requests, this is to be done by a higher-level crate.

All of the requests implement RemoteCall. This trait's associated type indicates what type the response from Telegram will be when invoked.

After opening one of the many types, you can inspect their fields to figure out what data Telegram will return.

Features

The default feature set is intended to make the use of the library comfortable, and not intended to be minimal in code size. If you need a smaller library or are concerned about build-times, consider disabling some of the default features.

The default feature set includes:

  • impl-debug.
  • impl-from-enum.
  • impl-from-type.
  • tl-api.

The available features are:

  • deserializable-functions: implements Deserializable for functions. This might be of interest for server implementations, which need to deserialize the client's requests, but is otherwise not required.

  • impl-debug: implements Debug for the generated code.

  • impl-from-enum: implements TryFrom<Enum> for Type.

  • impl-from-type: implements From<Type> for Enum.

  • tl-api: generates code for the api.tl. This is what high-level libraries often need.

  • tl-mtproto: generates code for the mtproto.tl. Only useful for low-level libraries.

No runtime deps