Expand description
§sf-client
Core HTTP client infrastructure for Salesforce APIs.
This crate provides the foundational HTTP client with:
- Automatic retry with exponential backoff and jitter
- Compression support (gzip, deflate)
- Rate limit detection and handling
- ETag/conditional request support
- Connection pooling
- Request/response tracing
§Architecture
┌─────────────────────────────────────────────────────────────┐
│ Application Layer │
│ (sf-rest, sf-bulk, sf-metadata, sf-tooling) │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ SalesforceClient │
│ - Holds credentials + HTTP client │
│ - Provides typed JSON methods (get_json, post_json, etc.) │
│ - Handles authentication headers │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ SfHttpClient │
│ - Raw HTTP with retry, compression, rate limiting │
│ - Request building with conditionals │
│ - Response handling │
└─────────────────────────────────────────────────────────────┘§Example
ⓘ
use sf_client::{SalesforceClient, ClientConfig};
use sf_auth::SalesforceCredentials;
#[tokio::main]
async fn main() -> Result<(), sf_client::Error> {
let creds = SalesforceCredentials::from_env()?;
let client = SalesforceClient::new(creds)?;
// Typed JSON request
let user: serde_json::Value = client
.get_json("/services/oauth2/userinfo")
.await?;
// POST with body
let result: CreateResult = client
.post_json("/services/data/v62.0/sobjects/Account", &new_account)
.await?;
Ok(())
}Re-exports§
pub use types::MetadataComponentDependency;
Modules§
- security
- Security utilities for Salesforce API operations.
- types
- Shared types used across multiple Salesforce API surfaces.
Structs§
- ApiUsage
- API usage information from response headers.
- Client
Config - Configuration for the HTTP client.
- Client
Config Builder - Builder for ClientConfig.
- Compression
Config - Configuration for request/response compression.
- Error
- Error type for sf-client operations.
- Query
Result - Result of a SOQL query.
- Request
Builder - Builder for HTTP requests with Salesforce-specific options.
- Response
- Wrapper around reqwest::Response with additional functionality.
- Retry
Config - Configuration for retry behavior.
- Retry
Policy - Retry policy that determines when and how to retry.
- Salesforce
Client - High-level Salesforce API client.
- SfHttp
Client - HTTP client for Salesforce APIs with built-in retry, compression, and error handling.
Enums§
- Backoff
Strategy - Backoff strategy for determining retry delays.
- Error
Kind - The kind of error that occurred.
- Request
Method - HTTP request method.
Constants§
- DEFAULT_
API_ VERSION - Default Salesforce API version
- USER_
AGENT - User-Agent string for the client
Traits§
- Response
Ext - Extension trait for processing Salesforce API responses.
Type Aliases§
- Result
- Result type alias for sf-client operations.