Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

tonstack/adnl-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

24 Commits

Repository files navigation

ADNL

crates.io documentation

Minimal client-server ADNL implementation in Rust. Specification of ADNL is available here.

Quickstart

Run this example: cargo run --example time

use adnl::AdnlPeer;
use base64::Engine as _;
use futures::{SinkExt, StreamExt};
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
 // decode liteserver public key
 let remote_public = base64::engine::general_purpose::STANDARD.decode("n4VDnSCUuSpjnCyUk9e3QOOd6o0ItSWYbTnW3Wnn8wk=")?;
 // act as a client: connect to ADNL server and perform handshake
 let mut client = AdnlPeer::connect(remote_public, "5.9.10.47:19949").await?;
 // already serialized TL with getTime query
 let query = hex::decode("7af98bb435263e6c95d6fecb497dfd0aa5f031e7d412986b5ce720496db512052e8f2d100cdf068c7904345aad16000000000000")?;
 // send over ADNL
 client.send(query.into()).await?;
 // receive result
 let result = client.next().await.ok_or_else(|| "no result")??;
 // get time from serialized TL answer
 println!(
 "received: {}",
 u32::from_le_bytes(result[result.len() - 7..result.len() - 3].try_into()?)
 );
 Ok(())
}

About

ADNL implementation in Rust

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

Languages

AltStyle によって変換されたページ (->オリジナル) /