Documentation

rtdlib

Build Status

rtdlib is TDLib for rust.

rtdlib crate have TDLib type (classes). and tdjson binding. not have client api. so if use rtdlib you need include libtdjson.so to you build path.

Build

rtdlib include a prebuilt td types, you can check types.rs, so rtdlib does not actively rebuild, if want. you can set an environment BUILD_TDAPI=true, when rtdlib check BUILD_TDAPI is true, will rebuild td type, and generate a new types.rs.

BUILD TYPE.RS IS VERY SLOW.

Notice

rtdlib build td type, use telegram official document, https://core.telegram.org/tdlib/docs/td__api_8h.html .

So there is a possibility of compilation failure.

It depends on whether the document has changed.

Usage

[dependencies]
rtdlib = "0.2"

type

let json =  r#"{"@type":"updateAuthorizationState","@struct":"UpdateAuthorizationState","authorization_state":{"@type":"authorizationStateWaitTdlibParameters","@struct":"AuthorizationStateWaitTdlibParameters"}}"#;
let state: UpdateAuthorizationState = serde_json::from_str(&json[..]).expect("Json fail");
assert_eq!("updateAuthorizationState", state.td_name());

tdjson

use rtdlib::tdjson::Tdlib;
let tdlib = Tdlib::new();
let request = r#"{"@type": "getMe"}"#;
tdlib.send(request);

and more document you need check telegram api

How include libtdjson.so

The first you need read td know how to build td.

And then, when you have libtdjson.so copy this file to /usr/lib.

Or set an environment

export RUSTFLAGS="-C link-args=-Wl,-rpath,/path/to/libtdjson.so"
cargo run

In the development phase, you can set RUSTFLAGS environment to you IDE.