Skip to main content

Crate truto

Crate truto 

Source
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.
ClientBuilder
Builder for Client.
ListResponse
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 .await it (or call Request::send) to get the decoded response.
RequestOptions
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.
ErrorBody
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-After header.
DEFAULT_TIMEOUT
Default per-attempt timeout.
RETRY_STATUS_CODES
Statuses that are always retried (unless retries are disabled).

Traits§

IntoQuery
Types accepted as query parameters: Query, a JSON object (serde_json::Value or serde_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§

DeleteResult
The result of a delete on resources typed as Record.
RateLimitHook
Called on a 429 before waiting, with (retry_after_seconds, retry_count). retry_count is 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>.
RetryHook
Called before each retry with (retry_count, status). retry_count starts at 1; status is None when the retry follows a connection error.