Expand description
Rust SDK for the Truto REST API. Guide: https://truto.one/docs/sdks/rust.
use futures_util::TryStreamExt;
use serde_json::json;
let client = truto::Client::new(std::env::var("TRUTO_API_TOKEN").unwrap());
// Admin resources return typed models.
let accounts = client.integrated_accounts().list().collect_all().await?;
// Data-plane APIs return dynamic records, paginated lazily.
let mut contacts = client
.unified_api()
.list("crm", "contacts", "integrated-account-id")
.query(json!({ "limit": 50 }))
.into_stream();
while let Some(contact) = contacts.try_next().await? {
println!("{:?}", contact.get("name"));
}Every method returns a builder: chain .query(..), .timeout(..),
.no_retry() and friends, then .await it. List methods return a
Pager.
Re-exports§
pub use resources::Uninstall;pub use serde_json;
Modules§
- models
- Typed models generated from Truto’s OpenAPI spec.
- resources
- Resource accessors. Get one from the client, e.g.
client.integrated_accounts(), then call a method to build a request.
Structs§
- ApiError
- A non-2xx response from the Truto API.
- Client
- A Truto API client. Cheap to clone: clones share one connection pool.
- Client
Builder - Builder for
Client. - List
Response - One page of a list endpoint, as the API sends it.
- Page
- One fetched page, from
Pager::next_page. - Pager
- A lazy pager over a cursor-paginated list endpoint.
- Query
- Query parameters for a request.
- RawResponse
- An undecoded successful response, from
Request::raw. - Request
- A single API call. Configure it with the chainable methods, then
.awaitit (or callRequest::send) to get the decoded response. - Request
Options - Per-request overrides. Every request builder exposes the same settings as
chainable methods (
.timeout(..),.no_retry(), …); this struct is for reusing one set of overrides across calls via.options(..).
Enums§
- Error
- Every error the SDK returns.
- Error
Body - The body of an error response: parsed JSON when the server sent JSON, otherwise the text as received.
Constants§
- DEFAULT_
BASE_ URL - Default API base URL.
- DEFAULT_
MAX_ RETRIES - Default number of retries after the first attempt.
- DEFAULT_
RETRY_ AFTER - Default wait after a 429 without a usable
Retry-Afterheader. - DEFAULT_
TIMEOUT - Default per-attempt timeout.
- RETRY_
STATUS_ CODES - Statuses that are always retried (unless retries are disabled).
Traits§
- Into
Query - Types accepted as query parameters:
Query, a JSON object (serde_json::Valueorserde_json::Map), or references to them.
Functions§
- decode
- Decode a
Record(or any JSON value) into your own type. - encode_
query - Encode a JSON object exactly like
qs.stringify(obj, { sort }).
Type Aliases§
- Delete
Result - The result of a delete on resources typed as
Record. - Rate
Limit Hook - Called on a 429 before waiting, with
(retry_after_seconds, retry_count).retry_countis the number of retries made so far. - Record
- A dynamic JSON object: the item type of the unified, proxy and custom APIs, and of resources the spec does not describe.
- Result
- Shorthand for
Result<T, truto::Error>. - Retry
Hook - Called before each retry with
(retry_count, status).retry_countstarts at 1;statusisNonewhen the retry follows a connection error.