marple-db
Rust client SDK for the MarpleDB API. The crate is published as marple-db and imported from Rust code as marple_db.
Installation
The SDK is async and works with any runtime supported by reqwest. The examples below use Tokio:
[]
= "0.1"
= { = "1", = ["rt-multi-thread", "macros"] }
= "1"
= "1"
Authentication
Create an API token in the MarpleDB web application and pass it to the SDK:
MDB_URL is optional for your own code, but the URL passed to MarpleDB::new should point at the API root and usually ends in /api/v1.
Quickstart
This example uploads run.csv to an existing stream named runs, waits for import to finish, and prints the final status.
use ;
use json;
use Duration;
async
Common Operations
db.health()checks the API health endpoint.db.get_streams()lists streams.db.get_stream("runs")finds a stream by name.db.create_stream("runs", &serde_json::json!({ "plugin": "csv" }))creates a stream.db.update_stream(stream_id, &serde_json::json!({ ... }))updates stream metadata.db.get_datasets(stream_id)lists datasets in a stream.db.get_datapool_datasets("default")lists datasets across a datapool.db.get_datapool_ingest_queue("default")lists datasets currently in the ingest queue.db.get_dataset(stream_id, dataset_id)fetches one dataset.db.push_file(stream_id, path, PushFileOptions::default())uploads a file.db.wait_for_import(stream_id, dataset_id, timeout)polls until import reaches a terminal status.db.get_download_link(&dataset)returns a pre-signed URL for the original uploaded file.db.get,db.post, anddb.deletecall API endpoints that do not have typed helpers yet.
Generic endpoint helpers deserialize into the type you ask for:
let response: Value = db
.post
.await?;
Use &() when a GET request has no query parameters:
let value: Value = db.get.await?;
Upload Options
push_file asks the server which upload mode to use and automatically handles direct storage uploads, multipart uploads, Azure block uploads, and API-server uploads.
use ;
use json;
let options = builder
.metadata
.concurrency
.upload_mode
.build;
UploadModeOverride::Server forces uploads through the MarpleDB API server. Leave the default Auto unless you need that behavior. concurrency is used by multipart/direct-storage upload modes; higher values can improve throughput but use more memory and network connections.
For progress reporting, implement ProgressReporter and pass it through PushFileOptions::builder().progress(...).
Downloading Original Files
get_download_link returns a pre-signed storage URL. The URL is already authenticated, so use db.storage_client() or another client that does not add MarpleDB authorization headers.
let url = db.get_download_link.await?;
let bytes = db.storage_client.get.send.await?.bytes.await?;
write?;
Custom Clients
Use MarpleDB::builder() when you need custom timeouts, user agents, or preconfigured reqwest::Client instances:
use MarpleDB;
use Duration;
let db = builder
.url
.token
.timeout
.user_agent
.build?;
Error Handling
The SDK returns marple_db::Error, which can be matched directly:
match db.get_stream.await
For HTTP-like failures, error.status() returns the API or storage status code when one is available.
Tracing
The SDK emits tracing spans/events for API calls and upload mode dispatch. It does not install a tracing subscriber; applications should configure their own subscriber if they want logs or spans.
Links
- Documentation: docs.marpledata.com
- Repository: github.com/marpledata/marple-sdk
- Issues: github.com/marpledata/marple-sdk/issues
- License: Apache-2.0 OR MIT