object-store-client

Crates.ioobject-store-client
lib.rsobject-store-client
version1.1.0
created_at2025-12-05 23:04:10.037693+00
updated_at2025-12-23 15:12:30.482521+00
descriptionAsync Rust client library for Object Storage Service - S3-compatible object storage
homepagehttps://github.com/metorial/object-storage
repositoryhttps://github.com/metorial/object-storage
max_upload_size
id1969370
size76,652
Tobias Herber (herber)

documentation

https://docs.rs/object-store-client

README

Object Storage Client for Rust

Async Rust client library for interacting with the Metorial Object Storage Service.

Installation

Add to your Cargo.toml:

[dependencies]
object-store-client = "0.1"
tokio = { version = "1", features = ["full"] }

Usage

use object_store_client::{ObjectStoreClient, Result};

#[tokio::main]
async fn main() -> Result<()> {
    let client = ObjectStoreClient::new("http://localhost:8080");

    // Create a bucket
    client.create_bucket("my-bucket").await?;

    // Upload an object
    let data = b"Hello, World!";
    client.put_object("my-bucket", "hello.txt", data, Some("text/plain"), None).await?;

    // Download an object
    let obj = client.get_object("my-bucket", "hello.txt").await?;
    println!("Downloaded {} bytes", obj.data.len());

    // List objects
    let objects = client.list_objects("my-bucket", None, None).await?;
    for obj in objects {
        println!("{}: {} bytes", obj.key, obj.size);
    }

    // Delete object
    client.delete_object("my-bucket", "hello.txt").await?;

    // Delete bucket
    client.delete_bucket("my-bucket").await?;

    Ok(())
}

API Reference

Client Creation

let client = ObjectStoreClient::new("http://localhost:8080");

Bucket Operations

Create Bucket

client.create_bucket("bucket-name").await?;

List Buckets

let buckets = client.list_buckets().await?;

Delete Bucket

client.delete_bucket("bucket-name").await?;

Object Operations

Put Object

let metadata = client.put_object(
    "bucket-name",
    "object-key",
    data,
    Some("application/json"),
    Some(custom_metadata)
).await?;

Get Object

let obj = client.get_object("bucket-name", "object-key").await?;

Head Object

let metadata = client.head_object("bucket-name", "object-key").await?;

Delete Object

client.delete_object("bucket-name", "object-key").await?;

List Objects

let objects = client.list_objects("bucket-name", Some("prefix/"), Some(100)).await?;

Error Handling

The client returns Result<T, Error> where Error can be:

  • Error::NotFound - Resource not found
  • Error::AlreadyExists - Resource already exists
  • Error::BadRequest - Invalid request
  • Error::ServerError - Server error
  • Error::Http - Network/HTTP error
Commit count: 0

cargo fmt