Skip to main content

Crate busbar_sf_client

Crate busbar_sf_client 

Source
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.
ClientConfig
Configuration for the HTTP client.
ClientConfigBuilder
Builder for ClientConfig.
CompressionConfig
Configuration for request/response compression.
Error
Error type for sf-client operations.
QueryResult
Result of a SOQL query.
RequestBuilder
Builder for HTTP requests with Salesforce-specific options.
Response
Wrapper around reqwest::Response with additional functionality.
RetryConfig
Configuration for retry behavior.
RetryPolicy
Retry policy that determines when and how to retry.
SalesforceClient
High-level Salesforce API client.
SfHttpClient
HTTP client for Salesforce APIs with built-in retry, compression, and error handling.

Enums§

BackoffStrategy
Backoff strategy for determining retry delays.
ErrorKind
The kind of error that occurred.
RequestMethod
HTTP request method.

Constants§

DEFAULT_API_VERSION
Default Salesforce API version
USER_AGENT
User-Agent string for the client

Traits§

ResponseExt
Extension trait for processing Salesforce API responses.

Type Aliases§

Result
Result type alias for sf-client operations.