RustSF
Thé most comprehensive Salesforce SDK for Rust, that supports most of the primary Salesforce APIs. It contains many examples and has very detailed documententation.
The currently supported Salesforce APIs with the latest version 67.0 (Summer 2026) are:
- Rest API, enabled via the feature
rest-api - Tooling API, enabled via the feature
tooling-api - Metadata API, enabled via the feature
metadata-api
It also supports the following APIs, but they still need a bit of work:
- Bulk API v1
- Bulk API v2
- Streaming API
And we have a number of APIs which are high on the wish list. If you are interested in contributing, please start a discussion with your suggestions.
- CPQ API
- Heroku Platform API
- Streaming API
Notes
This repo was forked from rustforce and a PR from tance77, for the rustforce repo seemed to be abandoned. The rustforce repo also lacked some important features and had some design flows around API versioning.
Usage
[]
= { = "0.0.2", = ["rest-api", "tooling-api", "metadata-api"] }
use ;
use Deserialize;
use env;
use Result;
async
Authentication
Username Password Flow (OAuth2)
let mut credentials = new;
credentials.set_client_id;
credentials.set_client_secret;
credentials.set_username;
credentials.set_password;
let mut client = new.await?;
Using an Existing Access Token
let mut credentials = new;
credentials.set_access_token;
credentials.set_instance_url;
let mut client = new.await?;
SFDX AUTH URL
let mut client = new.await?;
REST API
All REST API methods are accessed through RestApi:
let mut api = new;
Query Records
let res: = api.query.await?;
Examples: Query, Query All, Query More
Find By Id
Finds a single record by its Salesforce ID. Example:
let account = api..await?;
CRUD Record operations
let account = Account ;
let res = api.create_sobject.await?;
let res = api.create.await?;
Examples:
- Create a single record Simple example or Alternative example
- Create
Update Record
api.update.await?;
Upsert Record
let res = api.upsert.await?;
println!; // 200 = updated, 201 = created
Delete Record
api.destroy.await?;
Describe Global
use DescribeGlobalResponse;
let res: DescribeGlobalResponse = api.describe_global.await?;
Describe SObject
use DescribeResponse;
let res: DescribeResponse = api.describe.await?;
Versions
use VersionResponse;
let versions: = api.versions.await?;
Search (SOSL)
use SearchResponse;
let res: SearchResponse = api.search_sosl.await?;
Bulk API v1
use BulkApi;
let mut bulk = new;
let res = bulk.create_job.await?;
Bulk API v2
use BulkApiV2;
let mut bulk = new;
let res = bulk.create_job.await?;