Skip to main content

Crate weedforge

Crate weedforge 

Source
Expand description

§weedforge

A Rust-first, Python-friendly SDK for SeaweedFS.

§Features

  • Clean Architecture: Domain, Application, Infrastructure layers
  • HA-aware: Multiple master support with failover
  • Async + Sync: Both async and blocking APIs
  • Type-safe: Strong typing with FileId as first-class entity

§Quick Start

use weedforge::WeedClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create client
    let client = WeedClient::builder()
        .master_url("http://localhost:9333")
        .build()?;

    // Upload a file
    let file_id = client.write(b"Hello, SeaweedFS!".to_vec(), Some("hello.txt")).await?;
    println!("Uploaded: {}", file_id);

    // Download the file
    let data = client.read(&file_id).await?;
    println!("Downloaded: {} bytes", data.len());

    // Get public URL
    let url = client.public_url(&file_id).await?;
    println!("Public URL: {}", url);

    Ok(())
}

§Blocking API

use weedforge::BlockingWeedClient;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = BlockingWeedClient::builder()
        .master_url("http://localhost:9333")
        .build()?;

    let file_id = client.write(b"Hello!".to_vec(), Some("hello.txt"))?;
    let data = client.read(&file_id)?;

    Ok(())
}

Re-exports§

pub use domain::AssignOptions;
pub use domain::AssignResult;
pub use domain::DomainError;
pub use domain::DomainResult;
pub use domain::FileId;
pub use domain::LookupResult;
pub use domain::UploadResult;
pub use domain::VolumeLocation;
pub use application::ImageParams;
pub use application::PublicUrlOptions;
pub use application::ReadOptions;
pub use application::ReadResult;
pub use application::ReplicaSelection;
pub use application::ResizeMode;
pub use application::WriteOptions;
pub use application::WriteResult;
pub use infrastructure::HaMasterClient;
pub use infrastructure::HaMasterClientBuilder;
pub use infrastructure::HttpClientConfig;
pub use infrastructure::HttpMasterClient;
pub use infrastructure::HttpVolumeClient;
pub use infrastructure::MasterSelectionStrategy;
pub use client::BlockingWeedClient;
pub use client::WeedClient;
pub use client::WeedClientBuilder;

Modules§

application
Application layer for weedforge.
client
Main client facade for weedforge.
domain
Domain layer for weedforge.
infrastructure
Infrastructure layer for weedforge.