1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//! # renamed
//!
//! Official Rust SDK for the [renamed.to](https://www.renamed.to) API.
//!
//! This crate provides a type-safe, async client for AI-powered document
//! renaming, PDF splitting, and data extraction.
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! 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:
//!
//! ```rust,no_run
//! use renamed::{RenamedClient, RenamedError};
//!
//! # async fn example() -> Result<(), 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),
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ## Async Jobs
//!
//! Some operations like PDF splitting are asynchronous. These return an
//! [`AsyncJob`] that can be polled for completion:
//!
//! ```rust,no_run
//! use renamed::{RenamedClient, PdfSplitOptions, SplitMode};
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! 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?;
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ## Configuration
//!
//! Use the builder pattern for custom configuration:
//!
//! ```rust,no_run
//! use renamed::RenamedClient;
//! use std::time::Duration;
//!
//! let client = RenamedClient::builder("rt_your_api_key")
//! .timeout(Duration::from_secs(60))
//! .max_retries(3)
//! .build();
//! ```
// Re-export main types at crate root for convenience
pub use ;
pub use ;
pub use ;
pub use ;
/// Prelude module for convenient imports.
///
/// ```rust
/// use renamed::prelude::*;
/// ```