Skip to main content

radion_sdk/
lib.rs

1//! Official, async-first, fully-typed Rust SDK for the [Radion](https://radion.app) platform.
2//!
3//! One [`Radion`] client, one API key. Today the SDK exposes the realtime
4//! (WebSocket) product surface and standalone [`webhooks`] helpers; further
5//! surfaces attach to the same client as they ship, so adopting them is
6//! purely additive.
7//!
8//! # Example
9//!
10//! ```no_run
11//! use futures_util::StreamExt;
12//! use radion_sdk::{Radion, realtime::{Channel, Payload, Subscription}};
13//!
14//! # async fn run() -> eyre::Result<()> {
15//! let radion = Radion::builder().api_key("sk_...").build()?;
16//! radion.realtime.connect().await?;
17//!
18//! let mut trades = radion.realtime.subscribe(Subscription::new("trading", Channel::Trading)).await?;
19//! while let Some(event) = trades.next().await {
20//!     if let Payload::Trading(trade) = event.data {
21//!         println!("{} {:?}", event.id, trade);
22//!     }
23//! }
24//! # Ok(())
25//! # }
26//! ```
27//!
28//! # Features
29//!
30//! - `realtime` *(default)* — the WebSocket product surface.
31//! - `rustls` *(default)* — rustls TLS backend (no system OpenSSL dependency).
32//! - `native-tls` — use the platform native TLS backend instead.
33//! - `compression` — inflate zlib-compressed realtime frames. Opt in per client
34//!   with `.compression(true)`.
35//! - `tracing` — emit [`tracing`](https://docs.rs/tracing) spans/events.
36//! - `webhooks` — consume webhook deliveries: signature verification and body
37//!   parsing. No async transport — works in any HTTP server.
38#![cfg_attr(docsrs, feature(doc_cfg))]
39#![warn(missing_docs)]
40#![forbid(unsafe_code)]
41
42mod client;
43mod config;
44mod error;
45
46pub use client::{Radion, RadionBuilder};
47pub use config::{DEFAULT_BASE_URL, DEFAULT_WS_URL, RadionConfig};
48pub use error::{RadionError, Result};
49
50#[cfg(any(feature = "realtime", feature = "webhooks"))]
51#[cfg_attr(docsrs, doc(cfg(any(feature = "realtime", feature = "webhooks"))))]
52pub mod realtime;
53
54#[cfg(feature = "webhooks")]
55#[cfg_attr(docsrs, doc(cfg(feature = "webhooks")))]
56pub mod webhooks;