s2_sdk/
lib.rs

1/*!
2Rust SDK for [s2.dev](https://s2.dev/).
3
4The Rust SDK provides ergonomic wrappers and utilities to interact with the
5[S2 API](https://s2.dev/docs/rest/records/overview).
6
7# Getting started
8
91. Ensure you have added [tokio](https://crates.io/crates/tokio) and [futures](https://crates.io/crates/futures) as dependencies.
10   ```bash
11   cargo add tokio --features full
12   cargo add futures
13   ```
14
151. Add the `s2-sdk` dependency to your project:
16
17   ```bash
18   cargo add s2-sdk
19   ```
20
211. Generate an access token by logging into the web console at [s2.dev](https://s2.dev/dashboard).
22
231. Perform an operation.
24
25   ```no_run
26    use s2_sdk::{
27        S2,
28        types::{ListBasinsInput, S2Config},
29    };
30
31    #[tokio::main]
32    async fn main() -> Result<(), Box<dyn std::error::Error>> {
33        let s2 = S2::new(S2Config::new("<YOUR_ACCESS_TOKEN>"))?;
34        let page = s2.list_basins(ListBasinsInput::new()).await?;
35        println!("My basins: {:?}", page.values);
36        Ok(())
37    }
38   ```
39
40See [`S2`] for account-level operations, [`S2Basin`] for basin-level operations,
41and [`S2Stream`] for stream-level operations.
42
43# Examples
44
45We have curated a bunch of examples in the
46[SDK repository](https://github.com/s2-streamstore/s2-sdk-rust/tree/main/examples)
47demonstrating how to use the SDK effectively:
48
49* [List all basins](https://github.com/s2-streamstore/s2-sdk-rust/blob/main/examples/list_all_basins.rs)
50* [Explicit stream trimming](https://github.com/s2-streamstore/s2-sdk-rust/blob/main/examples/explicit_trim.rs)
51* [Producer](https://github.com/s2-streamstore/s2-sdk-rust/blob/main/examples/producer.rs)
52* [Consumer](https://github.com/s2-streamstore/s2-sdk-rust/blob/main/examples/consumer.rs)
53* and many more...
54
55This documentation is generated using
56[`rustdoc-scrape-examples`](https://doc.rust-lang.org/rustdoc/scraped-examples.html),
57so you will be able to see snippets from examples right here in the
58documentation.
59
60# Feedback
61
62We use [Github Issues](https://github.com/s2-streamstore/s2-sdk-rust/issues)
63to track feature requests and issues with the SDK. If you wish to provide
64feedback, report a bug or request a feature, feel free to open a Github
65issue.
66
67# Quick Links
68
69* [S2 Website](https://s2.dev)
70* [S2 Documentation](https://s2.dev/docs)
71* [CHANGELOG](https://github.com/s2-streamstore/s2-sdk-rust/blob/main/CHANGELOG.md)
72*/
73
74#![doc(
75    html_favicon_url = "https://raw.githubusercontent.com/s2-streamstore/s2-sdk-rust/main/assets/s2-black.png"
76)]
77#![doc(
78    html_logo_url = "https://raw.githubusercontent.com/s2-streamstore/s2-sdk-rust/main/assets/s2-black.png"
79)]
80#![warn(missing_docs)]
81
82#[rustfmt::skip]
83mod api;
84mod session;
85
86pub mod batching;
87mod ops;
88pub mod producer;
89mod retry;
90pub mod types;
91
92pub use ops::{S2, S2Basin, S2Stream};
93/// Append session for pipelining multiple appends with backpressure control.
94///
95/// See [`AppendSession`](append_session::AppendSession).
96pub mod append_session {
97    pub use crate::session::append::{
98        AppendSession, AppendSessionConfig, BatchSubmitPermit, BatchSubmitTicket,
99    };
100}