img-src Rust SDK
Developer-friendly & type-safe Rust SDK specifically catered to leverage img-src API.
Summary
img-src API: Image processing and delivery API.
A serverless image processing and delivery API built on Cloudflare Workers with parameter-driven image transformation and on-demand transcoding.
Features
- Image Upload: Store original images in R2 with SHA256-based deduplication
- On-Demand Transformation: Resize, crop, and convert images via URL parameters
- Format Conversion: WebP, AVIF, JPEG, PNG output formats
- Path Organization: Organize images into folders with multiple paths per image
- CDN Caching: Automatic edge caching for transformed images
Authentication
Authenticate using API Keys with imgsrc_ prefix. Create your API key at https://img-src.io/settings
Rate Limiting
- Free Plan: 100 requests/minute
- Pro Plan: 500 requests/minute
Rate limit headers are included in all responses.
Table of Contents
SDK Installation
Add the SDK as a dependency to your Cargo.toml:
[]
= "0.2.0"
Or install via cargo:
SDK Example Usage
Upload and Transform Images
use Configuration;
use images_api;
use env;
async
Authentication
Per-Client Security Schemes
This SDK supports the following security scheme globally:
| Name | Type | Scheme |
|---|---|---|
BearerAuth |
http | HTTP Bearer |
You can configure it by setting the bearer_access_token field in the Configuration struct. For example:
use Configuration;
use settings_api;
async
Create your API key at https://img-src.io/settings.
Available Resources and Operations
Images
- upload_image - Upload image
- list_images - List images
- search_images - Search images
- get_image - Get image metadata
- delete_image - Delete image
- create_signed_url - Create signed URL
- delete_image_path - Delete image path
Presets
- list_presets - List presets
- create_preset - Create preset
- get_preset - Get preset
- update_preset - Update preset
- delete_preset - Delete preset
Settings
- get_settings - Get user settings
- update_settings - Update user settings
Usage
- get_usage - Get usage statistics
Error Handling
Handling errors in this SDK should largely match your expectations. All operations return a Result type, they will never panic.
By default, an API error will return Error<T>. You can handle errors using pattern matching:
use Configuration;
use settings_api;
async
Server Selection
Override Server URL Per-Client
The default server can be overridden globally by setting the base_path field in the Configuration struct. For example:
use Configuration;
let mut config = new;
config.base_path = "https://api.img-src.io".to_string;
config.bearer_access_token = Some;
Custom HTTP Client
The Rust SDK makes API calls using reqwest. You can customize the HTTP client by providing your own reqwest::Client instance:
use Configuration;
use Client;
use Duration;
let http_client = builder
.timeout
.build
.unwrap;
let mut config = new;
config.client = http_client;
config.bearer_access_token = Some;
This can be a convenient way to configure timeouts, proxies, custom headers, and other low-level configuration.
Documentation For Models
- AvailableFormats
- CdnUrls
- CreatePresetRequest
- CreateSignedUrlRequest
- CreateSignedUrlRequestTransformation
- CurrentPeriod
- DeletePresetResponse
- DeleteResponse
- ErrorDetail
- ErrorResponse
- FolderItem
- HateoasLinks
- ImageDimensions
- ImageListItem
- ImageListResponse
- ImageMetadata
- ListPresetsResponse
- MetadataResponse
- PathDeleteResponse
- PlanLimits
- Preset
- SearchResponse
- SearchResult
- SettingsResponse
- SettingsUpdateResponse
- SignedUrlResponse
- UpdatePresetRequest
- UpdateSettingsRequest
- UploadResponse
- UsageResponse
- UserSettings
To get access to the crate's generated documentation, use:
Development
Maturity
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
Contributions
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
Author
For more information, please visit https://docs.img-src.io
