Skip to content

Commit

Permalink
Add docs for types module
Browse files Browse the repository at this point in the history
  • Loading branch information
Desiders committed Sep 16, 2023
1 parent a4fccd7 commit 7970147
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
//! This module contains telegram types from the [Telegram Bot API](https://core.telegram.org/bots/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`],
//! - 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 string, it will be represented as [`String`],
//! - is a number, it will be represented as [`i64`].
//! - 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:
//! - [`BotCommandScopeDefault`]
//! - [`BotCommandScopeAllPrivateChats`]
//! - [`BotCommandScopeAllGroupChats`]
//! - [`BotCommandScopeAllChatAdministrators`]
//! - [`BotCommandScopeChat`]
//! - [`BotCommandScopeChatAdministrators`]
//! - [`BotCommandScopeChatMember`]
//! Each variant has an implementation of [`From`] trait to convert from the variant to the [`BotCommandScope`],
//! so you can write `from` and `into` to convert between them instead of boilerplate code.
//! Many methods in the library accept "union" and tagged types as generic parameters with `Into` trait bounds,
//! so you can pass any of the variants to them.
pub mod animation;
pub mod audio;
pub mod bot_command;
Expand Down

0 comments on commit 7970147

Please sign in to comment.