Expand description
Async Rust SDK primitives for the CloudConvert API v2.
This crate exposes typed request and response models for CloudConvert jobs
and tasks, plus a CloudConvertClient for calling the API from async Rust
applications. Operation-specific drift is handled through option(...)
builder methods, extra maps, and TaskRequest::custom.
§Build jobs
Use JobCreateRequest::linear when each task feeds into the next task.
use cloudconvert_sdk::{FileExtension, JobCreateRequest};
let request = JobCreateRequest::linear()
.import_url("https://example.test/input.docx")
.convert(FileExtension::Pdf)?
.export_url()?
.build();
let payload = serde_json::to_value(request).unwrap();
assert_eq!(payload["tasks"]["import-url"]["operation"], "import/url");
assert_eq!(payload["tasks"]["convert"]["input"], "import-url");
assert_eq!(payload["tasks"]["export-url"]["input"], "convert");Use *_with(...) methods to configure task-specific options while keeping a
serial pipeline.
use cloudconvert_sdk::{FileExtension, JobCreateRequest};
let request = JobCreateRequest::linear()
.import_url_with("https://example.test/input.docx", |task| {
task.filename("input.docx")
})
.convert_with(FileExtension::Pdf, |task| {
task.input_format(FileExtension::Docx)
})?
.export_url()?
.build();
let payload = serde_json::to_value(request).unwrap();
assert_eq!(payload["tasks"]["import-url"]["filename"], "input.docx");
assert_eq!(payload["tasks"]["convert"]["input_format"], "docx");Use JobCreateRequest::graph when a job branches, joins multiple inputs,
or needs to reference a non-adjacent task.
use cloudconvert_sdk::{FileExtension, JobCreateRequest};
let request = JobCreateRequest::graph(|job| {
let import = job.import_url("https://example.test/input.docx");
let pdf = job.convert(&import, FileExtension::Pdf);
let png = job.convert(&import, FileExtension::Png);
job.export_url([&pdf, &png]);
})
.build();
let payload = serde_json::to_value(request).unwrap();
assert_eq!(payload["tasks"]["convert"]["input"], "import-url");
assert_eq!(payload["tasks"]["convert-2"]["input"], "import-url");
assert_eq!(
payload["tasks"]["export-url"]["input"],
serde_json::json!(["convert", "convert-2"])
);§Call the API
Live API calls need a CloudConvert API key. ApiKey::from_env() reads
CLOUDCONVERT_API_KEY.
use cloudconvert_sdk::{ApiKey, CloudConvertClient, FileExtension, JobCreateRequest};
let client = CloudConvertClient::builder(ApiKey::from_env()?).build()?;
let request = JobCreateRequest::linear()
.import_url("https://example.test/input.docx")
.convert(FileExtension::Pdf)?
.export_url()?
.build();
let job = client.jobs().create(request).await?;
let finished = client.jobs().wait(&job.id).await?;
for file in finished.export_urls() {
if let Some(url) = &file.url {
let bytes = client.download(url).await?;
println!("downloaded {} bytes as {}", bytes.len(), file.filename);
}
}Structs§
- ApiError
- Borrowed view of a CloudConvert HTTP error body and rate-limit headers.
- ApiKey
- CloudConvert API key used as a bearer token.
- ApiResponse
- A non-paginated API response that preserves envelope metadata.
- Archive
Task - Azure
Blob Export Task - Azure
Blob Import Task - Base64
Import Task - Capture
Website Task - Client
Builder - Configures credentials, base URLs, transport, and optional retry before build.
- Cloud
Convert Client - Entry point for authenticated CloudConvert API calls and file transfer.
- Cloud
Convert Config - Resolved client settings produced by
ClientBuilder::build. - Command
Task - Convert
Task - Export
Upload Task - Export
UrlTask - File
Result - One exported file entry, usually from an
export/urltask. - Generic
Task - Builder for a custom CloudConvert task operation.
- Google
Cloud Storage Export Task - Google
Cloud Storage Import Task - Import
Upload Task - Import
UrlTask - Invalid
Builder State - Error returned when a job builder method is called in an invalid state.
- Job
- CloudConvert job returned by create, get, wait, and list endpoints.
- JobBuilder
- Builder for serial
JobCreateRequestpipelines. - JobCreate
Request - Request body for
POST /v2/jobs. - JobGet
Query - Query parameters for
GET /v2/jobs/{id}and sync wait endpoints. - JobGraph
Builder - Builder for branched CloudConvert job graphs.
- JobList
Query - Query parameters for
GET /v2/jobs. - JobTask
- Task snapshot embedded in a
Jobresponse. - Jobs
Resource - Job REST endpoints, including sync wait and optional Socket.IO wait helpers.
- Merge
Task - Metadata
Task - Metadata
Write Task - OAuth
Access Token - OAuth access token used as a bearer token for API calls.
- OAuth
Client - OAuth client used to start authorization flows and exchange tokens.
- OAuth
Client Secret - OAuth client secret used during authorization-code and refresh flows.
- OAuth
Refresh Token - OAuth refresh token exchanged for a new access token.
- OAuth
Token Response - Token payload returned by CloudConvert OAuth token endpoints.
- Open
Stack Export Task - Open
Stack Import Task - Operation
- One supported CloudConvert operation with engines, options, and alternatives.
- Operation
Engine Version - Engine version entry attached to an
Operationmetadata record. - Operation
List Query - Query parameters for
GET /v2/operations. - Operation
Option - Documented option schema for a CloudConvert operation.
- Operation
Validation Error - Validation failure describing which operation field or option was rejected.
- Operations
Resource - Operations metadata listing engines, formats, and documented options.
- Optimize
Task - Page
- A paginated API response.
- Pagination
Links - Pagination links returned by CloudConvert list endpoints.
- Pagination
Meta - Pagination metadata returned by CloudConvert list endpoints.
- Parse
File Extension Error - Error returned when parsing a string into
FileExtensionfails. - PdfA
Task - PdfDecrypt
Task - PdfEncrypt
Task - PdfExtract
Pages Task - PdfOcr
Task - PdfRotate
Pages Task - PdfSplit
Pages Task - PdfX
Task - Rate
Limit - Rate limit information extracted from CloudConvert response headers.
- RawImport
Task - S3Export
Task - S3Import
Task - Sftp
Export Task - Sftp
Import Task - Signing
Secret - Shared secret for signing job URLs and webhook payloads.
- Socket
Subscription - Bearer-authenticated subscribe payload sent to the Socket.IO server.
- Task
- Standalone CloudConvert task returned by task endpoints.
- Task
GetQuery - Query parameters for
GET /v2/tasks/{id}. - Task
List Query - Query parameters for
GET /v2/tasks. - Task
Name - Name assigned to a task in a CloudConvert job request.
- Task
Request - Serialized task request used by job and standalone task APIs.
- Task
Result - Task output payload containing exported files or an upload form.
- Tasks
Resource - Standalone task REST endpoints and optional Socket.IO wait helpers.
- Thumbnail
Task - Transport
Config - Optional
reqwesttimeouts and user agent applied when building HTTP clients. - Upload
Form - Presigned multipart upload target for an
import/uploadtask. - User
- Authenticated CloudConvert account returned by
GET /v2/users/me. - Users
Resource - Account endpoints and helpers that resolve user-scoped Socket.IO channels.
- Watermark
Task - Webhook
- Registered webhook subscription, including optional signing secret metadata.
- Webhook
Create Request - Request body for
POST /v2/webhooks. - Webhook
List Query - Query parameters for listing registered webhooks.
- Webhooks
Resource - Webhook registration endpoints for the authenticated account.
Enums§
- Error
- Top-level failure type for API, transport, builder, and validation errors.
- File
Extension - Supported CloudConvert file extension tokens.
- Font
Align - Input
- Input dependency for a CloudConvert task.
- Invalid
Builder State Kind - Specific reason a job builder rejected the current call sequence.
- JobSocket
Event - Job lifecycle event names emitted over Socket.IO.
- JobStatus
- Lifecycle status returned for a CloudConvert job.
- Layer
- OAuth
Scope - OAuth scope token requested during authorization.
- Operation
Option Kind - Declared value type for an operation option in metadata responses.
- Operation
Validation Error Kind - Specific validation failure category for an operation or option check.
- Operation
Validation Mode - Controls whether undocumented task options are accepted during validation.
- Position
Horizontal - Position
Vertical - Region
- Regional API hostname prefix for non-sandbox clients.
- Socket
Channel - Socket.IO channel selector for job, task, or user-scoped event streams.
- Socket
Event Kind - Parsed Socket.IO event name, including unknown custom events.
- Task
Socket Event - Task lifecycle event names emitted over Socket.IO.
- Task
Status - Lifecycle status returned for a CloudConvert task.
- Webhook
Event - Event name CloudConvert can deliver to a registered webhook URL.
Traits§
- Task
Payload - Sealed trait implemented by SDK-owned typed task builders.
Functions§
- sign_
job_ url - Builds a signed job URL that embeds the serialized job request in the query string.
- sign_
payload - Computes the HMAC-SHA256 hex digest CloudConvert uses for webhook payloads.
- socket_
base_ url - Socket.IO base URL for production or sandbox environments.
- verify_
signature - Returns
truewhensignature_hexmatches the HMAC-SHA256 digest ofpayload.
Type Aliases§
- Extra
Options - Open-ended operation options serialized beside typed task fields.
- Operation
Validation Result - Result of validating a
TaskRequestagainst anOperationrecord. - Result
- Convenience result alias used throughout the crate.