| Crates.io | lattice-sdk |
| lib.rs | lattice-sdk |
| version | 0.1.3 |
| created_at | 2025-10-28 12:32:56.276771+00 |
| updated_at | 2025-10-28 13:22:59.518319+00 |
| description | Rust SDK for lattice_sdk generated by Fern |
| homepage | |
| repository | https://github.com/fern-api/fern |
| max_upload_size | |
| id | 1904701 |
| size | 348,115 |
The Lattice SDK Rust library provides convenient access to the Lattice SDK APIs from Rust.
API reference documentation is available here.
Add this to your Cargo.toml:
[dependencies]
lattice_sdk = "0.1.0"
Or install via cargo:
cargo add lattice_sdk
A full reference for this library is available here.
Instantiate and use the client with the following:
use lattice_sdk::prelude::*;
#[tokio::main]
async fn main() {
let config = ClientConfig {
token: Some("<token>".to_string()),
..Default::default()
};
let client = LatticeClient::new(config).expect("Failed to build client");
client
.entities
.long_poll_entity_events(
&EntityEventRequest {
session_token: "sessionToken".to_string(),
},
None,
)
.await;
}
When the API returns a non-success status code (4xx or 5xx response), an error will be returned.
match client.entities.long_poll_entity_events(None)?.await {
Ok(response) => {
println!("Success: {:?}", response);
},
Err(ApiError::HTTP { status, message }) => {
println!("API Error {}: {:?}", status, message);
},
Err(e) => {
println!("Other error: {:?}", e);
}
}
The SDK exports all request types as Rust structs. Simply import them from the crate to access them:
use lattice_sdk::prelude::{*};
let request = EntityOverride {
...
};
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retryable and the number of retry attempts has not grown larger than the configured retry limit (default: 2).
A request is deemed retryable when any of the following HTTP status codes is returned:
Use the max_retries method to configure this behavior.
let response = client.entities.long_poll_entity_events(
Some(RequestOptions::new().max_retries(3))
)?.await;
The SDK defaults to a 30 second timeout. Use the timeout method to configure this behavior.
let response = client.entities.long_poll_entity_events(
Some(RequestOptions::new().timeout_seconds(30))
)?.await;
You can add custom headers to requests using RequestOptions.
let response = client.entities.long_poll_entity_events(
Some(
RequestOptions::new()
.additional_header("X-Custom-Header", "custom-value")
.additional_header("X-Another-Header", "another-value")
)
)?
.await;
You can add custom query parameters to requests using RequestOptions.
let response = client.entities.long_poll_entity_events(
Some(
RequestOptions::new()
.additional_query_param("filter", "active")
.additional_query_param("sort", "desc")
)
)?
.await;