ksqldb/lib.rs
1//! # KSQL DB
2//!
3//! This crate is a thin wrapper around the [KSQL-DB](https://ksqldb.io/) REST API
4//! to make interacting with the API more ergonomic for Rust projects. Under the
5//! hood it uses [reqwest](https://docs.rs/reqwest/latest) as a HTTP client to
6//! interact with the API.
7//!
8//! ## Quickstart
9//!
10//! ```no_run
11//! use reqwest::Client;
12//! use ksqldb::KsqlDB;
13//! use futures_util::stream::StreamExt;
14//! use serde::Deserialize;
15//!
16//! #[derive(Debug, Deserialize)]
17//! struct MyResponse {
18//! id: String,
19//! data: Vec<u32>
20//! }
21//!
22//! #[tokio::main]
23//! async fn main() {
24//! let ksql = KsqlDB::new("localhost:8080".into(), Client::builder(), false).unwrap();
25//!
26//! let statement = r#"SHOW STREAMS EXTENDED;"#;
27//! let response = ksql.list_streams(&statement, &Default::default(), None).await.unwrap();
28//! println!("{:#?}", response);
29//!
30//! let query = r#"SELECT * FROM MY_STREAM EMIT CHANGES;"#;
31//!
32//! let mut stream = ksql.select::<MyResponse>(&query, &Default::default()).await.unwrap();
33//!
34//! while let Some(data) = stream.next().await {
35//! println!("{:#?}", data);
36//! }
37//! }
38//! ```
39mod client;
40pub mod error;
41pub(crate) mod stream;
42pub mod types;
43
44pub use client::KsqlDB;
45pub use error::{Error, KsqlDBError};
46
47/// The result type for this library
48pub type Result<T> = std::result::Result<T, Error>;
49
50#[cfg(all(feature = "http2", feature = "http1"))]
51compile_error!(
52 r#"
53 features `ksqldb/http2` and `ksqldb/http1` are mutually exclusive.
54 If you are trying to disable http2 set `default-features = false`.
55"#
56);