Expand description
Rust SDK for S2.
The Rust SDK provides ergonomic wrappers and utilities to interact with the S2 API.
§Getting started
-
Ensure you have added tokio and futures as dependencies.
cargo add tokio --features full cargo add futures -
Add the
s2-sdkdependency to your project:cargo add s2-sdk -
Generate an access token by logging into the web console at s2.dev.
-
Perform an operation.
use s2_sdk::{ S2, types::{ListBasinsInput, S2Config}, }; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let s2 = S2::new(S2Config::new("<YOUR_ACCESS_TOKEN>"))?; let page = s2.list_basins(ListBasinsInput::new()).await?; println!("My basins: {:?}", page.values); Ok(()) }
See S2 for account-level operations, S2Basin for basin-level operations,
and S2Stream for stream-level operations.
§Examples
We have curated a bunch of examples in the repository demonstrating how to use the SDK effectively:
This documentation is generated using
rustdoc-scrape-examples,
so you will be able to see snippets from examples right here in the
documentation.
§Integration tests with s2-lite
Use s2-testcontainers
to start s2-lite from the S2 Docker image and get an SDK client/config without
manual Docker port allocation, endpoint plumbing, or health polling. See the
s2_lite example
for the canonical setup.
§Feedback
We use Github Issues to track feature requests and issues with the SDK. If you wish to provide feedback, report a bug or request a feature, feel free to open a Github issue.
§Quick Links
Modules§
- append_
session - Append session for pipelining multiple appends with backpressure control.
- batching
- Utilities for batching AppendRecords.
- producer
- High-level producer for appending records to streams.
- read_
session - Continuous read sessions.
- types
- Types relevant to
S2,S2Basin, andS2Stream.