ton_net_lite/lib.rs
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: 2026 Nirapod Labs
3
4// A library that decodes bytes from a peer it does not trust must fail by returning, not
5// by unwinding: a panic in a decoder is a denial of service in whatever process embedded
6// it. The lints sit on the library because a test is the opposite case, where an unwrap
7// is the assertion. Arithmetic is deliberately not in the set: every count these formats
8// carry is bounded before it is used, and each subtraction sits within a few lines of the
9// guard that makes it safe, so denying it would bury the real bounds under checked_sub.
10#![deny(
11 clippy::unwrap_used,
12 clippy::expect_used,
13 clippy::panic,
14 clippy::unreachable,
15 clippy::todo,
16 clippy::indexing_slicing
17)]
18
19//! Liteserver read client for ton-net.
20//!
21//! [`LiteClient`] speaks the liteserver query protocol over an ADNL connection and
22//! decodes the read responses into the domain types this crate defines. Nothing here
23//! checks anything: a read comes back as a [`ServerReported`] value, and the proof
24//! bytes travel with it for the layer above to verify.
25//!
26//! [`LiteClient::masterchain_info`] reads the current masterchain head,
27//! [`LiteClient::account_state`] reads an account's raw state at a given block, and
28//! [`LiteClient::block_proof`] asks for the links between two blocks. The facade above
29//! this crate wraps a `LiteClient` over a TCP transport and adds address parsing and a
30//! bundled config.
31//!
32//! This crate maps the wire types from ton-net-tl into cleaner domain types: block
33//! sequence numbers become unsigned, and a response keeps only what a reader needs. The
34//! block-proof types are the exception and are re-exported as they come off the wire,
35//! because their reader is a verifier rather than a person. It is an internal crate of
36//! the ton-net client.
37#![forbid(unsafe_code)]
38#![warn(missing_docs)]
39#![deny(rustdoc::broken_intra_doc_links)]
40
41mod client;
42mod types;
43
44pub use client::{LiteClient, LiteError};
45pub use types::{AccountState, BlockIdExt, MasterchainInfo, ServerReported};
46
47/// An account identifier: a workchain and a 256-bit account id.
48///
49/// This is the account [`LiteClient::account_state`] reads, re-exported from ton-net-tl.
50/// The facade builds one from a parsed address.
51pub use ton_net_tl::lite::AccountId;
52
53/// The block-proof types [`LiteClient::block_proof`] answers with, re-exported from
54/// ton-net-tl so a caller need not name that crate to read a chain.
55pub use ton_net_tl::lite::{BlockLink, PartialBlockProof, Signature, SignatureSet};
56
57// The README ships to crates.io and cannot be replaced once a version is published,
58// so its examples are compiled here rather than trusted. Doc-only: this does not
59// appear in the rendered documentation.
60#[cfg(doctest)]
61#[doc = include_str!("../README.md")]
62struct Readme;