docling_rs
Rust SDK for Docling Serve. Convert PDFs, DOCX, PPTX, images, and more into Markdown, JSON, HTML, or plain text.
Features
- Async-first HTTP client — Built on
reqwestwith full async/await support - Synchronous API — Blocking wrapper available via feature flag for simple scripts
- URL & file conversion — Convert from HTTP URLs or upload local files via multipart
- Sync & async job handling — Block until done, or submit and poll for large documents
- Fully typed — All enums and models matching OpenAPI 3.1 spec (v1.12.0)
- API key authentication — Bearer token support for secured endpoints
- Structured errors — Typed errors for network, API, JSON, I/O, task failures, timeouts
- Zero unsafe code
Installation
[]
= "0.1"
All dependencies (including tokio for the internal runtime) are included automatically.
Feature Flags
| Feature | Default | Description |
|---|---|---|
blocking |
✅ | Enables synchronous API in docling_rs::blocking. |
Using without blocking API
For smaller binary size when you only need async:
[]
= { = "0.1", = false }
Quick Start
Blocking API (Simplest)
No async boilerplate needed. Works in any Rust program:
use DoclingClient;
Async API
For integration with async Rust code. Requires tokio for the async runtime:
[]
= "0.1"
= { = "1", = ["macros", "rt-multi-thread"] }
use DoclingClient;
async
Examples
# Run Docling Serve
# Run examples
API Overview
Blocking API
use DoclingClient;
let client = new;
// Health & version
client.health?;
client.version?;
// Basic conversion (options is owned: Option<ConvertDocumentsRequestOptions>)
let result = client.convert_source?;
// File upload (options is borrowed: Option<&ConvertDocumentsRequestOptions>)
let result = client.convert_file?;
// Async with polling (blocking wrapper)
let task = client.convert_source_async?;
let status = client.poll_task_status?;
let result = client.get_task_result?;
// Convenience methods
let result = client.wait_for_conversion?;
let result = client.wait_for_file_conversion?;
Async API
use DoclingClient;
let client = new;
// Health & version
client.health.await?;
client.version.await?;
// Basic conversion (options is owned: Option<ConvertDocumentsRequestOptions>)
let result = client.convert_source.await?;
// File upload (options is borrowed: Option<&ConvertDocumentsRequestOptions>)
let result = client.convert_file.await?;
// Async with polling
let task = client.convert_source_async.await?;
let status = client.poll_task_status.await?;
let result = client.get_task_result.await?;
// Convenience methods
let result = client.wait_for_conversion.await?;
let result = client.wait_for_file_conversion.await?;
Error Handling
Both APIs return the same DoclingError variants:
use DoclingClient;
use DoclingError;
let client = new;
match client.convert_source
License
MIT