Skip to main content

tessera/
lib.rs

1//! # tessera
2// Brand names read fine without markup; keep the prose clean.
3#![allow(clippy::doc_markdown)]
4//!
5//! The official Rust client for [Tessera](https://tesseralytics.dev) —
6//! order-flow-enriched OHLCV, funding-rate, and positioning datasets built
7//! from raw Hyperliquid trade data, delivered as Parquet over a REST API.
8//!
9//! This crate is the Rust mirror of the
10//! [`tessera-api`](https://pypi.org/project/tessera-api/) Python SDK: point it
11//! at a `(dataset, coin, month)` and read straight from object storage into
12//! [Polars](https://pola.rs) or [DuckDB](https://duckdb.org) over presigned
13//! URLs — with predicate/projection pushdown, no temp files.
14//!
15//! ## Choosing a client
16//!
17//! - [`TesseraClient`] — blocking API. Owns a private tokio runtime, so do not
18//!   construct it from inside an async runtime.
19//! - [`AsyncTesseraClient`] — `async fn` surface for tokio applications.
20//!
21//! ## Data engines
22//!
23//! - Polars (default feature `polars`): [`TesseraClient::scan`] returns a
24//!   `LazyFrame`; [`TesseraClient::read`] collects a `DataFrame`.
25//! - DuckDB (opt-in feature `duckdb`): `TesseraClient::to_duckdb` returns an
26//!   in-memory connection exposing a `tessera` view.
27//!
28//! ## Errors
29//!
30//! Every failure raises [`TesseraError`], mirroring the Python exception
31//! taxonomy (`Configuration`, `NotFound`, `PresignExpired`, …).
32//!
33//! ## Example
34//!
35//! ```no_run
36//! # fn main() -> Result<(), tessera::TesseraError> {
37//! let client = tessera::TesseraClient::new(None)?;
38//! // Pick the newest available month rather than a hardcoded one:
39//! // partitions roll on a 12-month window, so fixed dates go stale.
40//! let latest = client
41//!     .partitions("gold_ohlcv_1m", Some("BTC"), None)?
42//!     .partitions
43//!     .pop()
44//!     .expect("at least one partition");
45//! let frame = client.read("gold_ohlcv_1m", "BTC", &latest.month, None)?;
46//! println!("{} rows for {}", frame.height(), latest.month);
47//! # Ok::<(), tessera::TesseraError>(())
48//! # }
49//! ```
50
51/// The crate version, as published on crates.io.
52pub const VERSION: &str = env!("CARGO_PKG_VERSION");
53
54mod async_client;
55mod base;
56mod client;
57mod config;
58mod error;
59mod models;
60/// Data-engine plumbing: Parquet readers for Polars and DuckDB.
61///
62/// Most users go through [`TesseraClient::scan`] / [`TesseraClient::read`] /
63/// `TesseraClient::to_duckdb`; the readers are public for advanced
64/// composition over pre-resolved URLs.
65pub mod readers;
66#[cfg(any(feature = "polars", feature = "duckdb"))]
67pub mod resolver;
68
69pub use crate::async_client::AsyncTesseraClient;
70pub use crate::client::TesseraClient;
71pub use crate::config::{API_KEY_ENV_VAR, ClientConfig, DEFAULT_BASE_URL, USER_AGENT};
72pub use crate::error::{TesseraError, error_from_response};
73pub use crate::models::{
74    DatasetSummary, DatasetsResponse, DownloadResponse, ErrorBody, IntoCoins, IntoMonths,
75    MonthRange, MonthSpan, Partition, PartitionRef, PartitionsResponse,
76};