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

pub use client::KsqlDB;
pub use error::{Error, KsqlDBError};

/// The result type for this library
pub type Result<T> = std::result::Result<T, Error>;

#[cfg(all(feature = "http2", feature = "http1"))]
compile_error!(
    r#"
    features `ksqldb/http2` and `ksqldb/http1` are mutually exclusive.
    If you are trying to disable http2 set `default-features = false`.
"#
);