Expand description
§renamed
Official Rust SDK for the renamed.to API.
This crate provides a type-safe, async client for AI-powered document renaming, PDF splitting, and data extraction.
§Quick Start
use renamed::{RenamedClient, RenameOptions};
#[tokio::main]
async fn main() -> Result<(), renamed::RenamedError> {
// Create a client with your API key
let client = RenamedClient::new("rt_your_api_key");
// Check your credits
let user = client.get_user().await?;
println!("Credits remaining: {}", user.credits.unwrap_or(0));
// Rename a file using AI
let result = client.rename("invoice.pdf", None).await?;
println!("Suggested name: {}", result.suggested_filename);
Ok(())
}§Features
- Rename: AI-powered file renaming based on content analysis
- PDF Split: Split multi-page PDFs into separate documents
- Extract: Extract structured data from documents
§Error Handling
All methods return Result<T, RenamedError>. The error type provides
specific variants for different failure modes:
use renamed::{RenamedClient, RenamedError};
let client = RenamedClient::new("rt_your_api_key");
match client.get_user().await {
Ok(user) => println!("Hello, {}!", user.email),
Err(RenamedError::Authentication { .. }) => {
eprintln!("Invalid API key");
}
Err(RenamedError::InsufficientCredits { .. }) => {
eprintln!("Please add more credits");
}
Err(RenamedError::RateLimit { retry_after, .. }) => {
if let Some(seconds) = retry_after {
eprintln!("Rate limited. Retry after {} seconds", seconds);
}
}
Err(e) => eprintln!("Error: {}", e),
}§Async Jobs
Some operations like PDF splitting are asynchronous. These return an
AsyncJob that can be polled for completion:
use renamed::{RenamedClient, PdfSplitOptions, SplitMode};
let client = RenamedClient::new("rt_your_api_key");
// Start the job
let job = client.pdf_split("multi-page.pdf", None).await?;
// Wait for completion with progress updates
let result = job.wait(Some(Box::new(|status| {
println!("Progress: {}%", status.progress.unwrap_or(0));
}))).await?;
// Process the results
for doc in result.documents {
let content = client.download_file(&doc.download_url).await?;
tokio::fs::write(&doc.filename, content).await?;
}§Configuration
Use the builder pattern for custom configuration:
use renamed::RenamedClient;
use std::time::Duration;
let client = RenamedClient::builder("rt_your_api_key")
.timeout(Duration::from_secs(60))
.max_retries(3)
.build();Modules§
- prelude
- Prelude module for convenient imports.
Structs§
- Async
Job - Represents an asynchronous job that can be polled for completion.
- Extract
Options - Options for the extract operation.
- Extract
Result - Result of an extract operation.
- JobStatus
Response - Response from the job status endpoint.
- PdfSplit
Options - Options for PDF split operation.
- PdfSplit
Result - Result of a PDF split operation.
- Rename
Options - Options for the rename operation.
- Rename
Result - Result of a rename operation.
- Renamed
Client - The main client for interacting with the renamed.to API.
- Renamed
Client Builder - Builder for configuring a
RenamedClient. - Split
Document - A single document from a PDF split operation.
- Team
- Team information.
- User
- User profile information.
Enums§
- JobStatus
- Status of an async job.
- Renamed
Error - The main error type for the renamed.to SDK.
- Split
Mode - Mode for PDF splitting.
Type Aliases§
- Progress
Callback - A callback function that receives progress updates during job polling.
- Result
- Type alias for Results using RenamedError.