Expand description
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
: implementsDeserializable
forfunctions
. This might be of interest for server implementations, which need to deserialize the client’s requests, but is otherwise not required. -
impl-debug
: implementsDebug
for the generated code. -
impl-from-enum
: implementsTryFrom<Enum> for Type
. -
impl-from-type
: implementsFrom<Type> for Enum
. -
tl-api
: generates code for theapi.tl
. This is what high-level libraries often need. -
tl-mtproto
: generates code for themtproto.tl
. Only useful for low-level libraries.
Re-exports§
pub use deserialize::Cursor;
pub use deserialize::Deserializable;
pub use serialize::Serializable;
Modules§
- deserialize
- enums
- This module contains all of the boxed types, each
represented by a
enum
. All of them implementSerializable
andDeserializable
. - functions
- This module contains all of the functions, each
represented by a
struct
. All of them implementIdentifiable
andSerializable
. - serialize
- types
- This module contains all of the bare types, each
represented by a
struct
. All of them implementIdentifiable
,Serializable
andDeserializable
.
Structs§
- Blob
- This struct represents an unparsed blob, which should not be deserialized as a bytes string. Used by functions returning generic objects which pass the underlying result without any modification or interpretation.
- RawVec
- This struct represents the concrete type of a vector, that is,
vector
as opposed to the typeVector
. This bare type is less common, so instead of creating a enum forVector
wrappingvector
as Rust’sVec
(as we would do with auto-generated code), a new-type forvector
is used instead.
Constants§
- LAYER
- The schema layer from which the definitions were generated.
Traits§
- Identifiable
- Anything implementing this trait is identifiable by both ends (client-server) when performing Remote Procedure Calls (RPC) and transmission of objects.
- Remote
Call - Structures implementing this trait indicate that they are suitable for use to perform Remote Procedure Calls (RPC), and know what the type of the response will be.
Functions§
- name_
for_ id - Return the name from the
.tl
definition corresponding to the provided definition identifier.