rtdlib
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
[]
= "0.2"
type
let json = r#"{"@type":"updateAuthorizationState","@struct":"UpdateAuthorizationState","authorization_state":{"@type":"authorizationStateWaitTdlibParameters","@struct":"AuthorizationStateWaitTdlibParameters"}}"#;
let state: UpdateAuthorizationState = from_str.expect;
assert_eq!;
tdjson
use Tdlib;
let tdlib = new;
let request = r#"{"@type": "getMe"}"#;
tdlib.send;
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
In the development phase, you can set RUSTFLAGS
environment to you IDE.