tdlib_types/
lib.rs

1extern crate serde;
2#[macro_use]
3extern crate serde_derive;
4extern crate serde_aux;
5
6pub mod types {
7include!(concat!(env!("OUT_DIR"), "/td_api_types.rs"));
8}
9
10pub mod methods {
11use super::types::*;
12use ::serde::de::DeserializeOwned;
13use ::serde::Serialize;
14use ::std::fmt::Debug;
15
16pub trait Method: Serialize+Clone {
17    const TYPE: &'static str;
18    type Response: DeserializeOwned+Debug;
19
20    fn tag(self) -> MethodType<Self>
21        where Self: ::std::marker::Sized {
22        MethodType {
23            type_: Self::TYPE,
24            payload: self,
25        }
26    }
27}
28#[derive(Serialize, Debug, Clone)]
29pub struct MethodType<T: Method> {
30    #[serde(rename="@type")]
31    pub type_: &'static str,
32    #[serde(flatten)]
33    pub payload: T,
34}
35
36include!(concat!(env!("OUT_DIR"), "/td_api_methods.rs"));
37}