opendeviationbar_client/lib.rs
1// Issue #170: opendeviationbar-client crate
2//! Client library for consuming open deviation bar data via SSE.
3//!
4//! Provides a typed Rust API for connecting to the ODB sidecar's SSE endpoint
5//! and receiving completed bars as a stream.
6//!
7//! # Example
8//!
9//! ```ignore
10//! use opendeviationbar_client::{OdbSseClient, OdbSseConfig, OdbSseEvent};
11//! use futures::StreamExt;
12//!
13//! let client = OdbSseClient::new(OdbSseConfig {
14//! host: "127.0.0.1".into(),
15//! port: 8081,
16//! symbols: vec!["BTCUSDT".into()],
17//! thresholds: vec![250],
18//! });
19//!
20//! let mut stream = std::pin::pin!(client.connect());
21//! while let Some(event) = stream.next().await {
22//! match event {
23//! OdbSseEvent::Bar(bar) => println!("{} @{}: {}", bar.symbol, bar.threshold, bar.close),
24//! OdbSseEvent::Connected => println!("connected"),
25//! OdbSseEvent::Heartbeat => {},
26//! OdbSseEvent::DeserializationError { error, .. } => eprintln!("bad bar: {error}"),
27//! OdbSseEvent::Disconnected(reason) => println!("disconnected: {reason}"),
28//! }
29//! }
30//! ```
31
32mod sse;
33mod transport;
34
35pub use sse::{OdbBar, OdbSseClient, OdbSseConfig, OdbSseEvent};