Module telers::types

source ·
Expand description

This module contains telegram types from the Telegram Bot API. Each type has a description and a link to the official documentation.

Telegram types are represented as Rust structs, if a field:

  • is optional, it will be wrapped in Option,
  • is an array, it will be wrapped in Vec or slice wrapped in Box,
  • is a recursive type, it will be wrapped in Box.
  • is a tagged union, it will be wrapped in enum with variants named as in the documentation,
  • is a type with optional fields, it can be represented as an enum with variants for specific cases (check Message for example).
  • is a string, it will be represented as String or str wrapped in Box,
  • is a number, it will be represented as i64 or u16 if it’s UTF-16 code unit,
  • is a float, it will be represented as f64,
  • is a boolean, it will be represented as bool,
  • is a file, it will be represented as InputFile,
  • is a chat id with kind (integer or string), it will be represented as ChatIdKind,
  • is a date, it will be represented as i64 (unix timestamp).

Tagged unions are represented as enums with variants named as in the documentation and we implement From trait for them to make it easier to convert from them to the enum. For example, BotCommandScope is represented as enum with variants:

The telegram type with optional fields can be represented as an enum with variants for specific cases. For example, Message is represented as enum with variants:

Re-exports§

Modules§