sia_storage
A Rust SDK for storing and retrieving data on the Sia decentralized storage network.
Sia is a decentralized cloud storage platform where data is stored across a global network of independent hosts. Storage contracts are enforced by the Sia blockchain, so no single party controls your data. Compared to centralized providers, Sia offers lower costs, stronger privacy (data is client-side encrypted by default), and censorship resistance.
This crate provides a high-level interface for interacting with Sia through an indexer service. Data is automatically erasure-coded, encrypted, and distributed across hosts.
Usage
Connecting for the first time
Use Builder to start the approval flow with an indexer. The user must approve the connection through the indexer's UI, after which an AppKey is derived from their recovery phrase.
use ;
const APP_META: AppMetadata = AppMetadata ;
let builder = new?;
let builder = builder.request_connection.await?;
// Display builder.response_url() to the user for approval
let builder = builder.wait_for_approval.await?;
let sdk = builder.register.await?;
// Save the app key for future connections
let exported = sdk.app_key.export;
Reconnecting with an existing key
use ;
let app_key = import;
let builder = new?;
if let Some = builder.connected.await?
Uploading and downloading
use ;
// Upload
let object = sdk.upload.await?;
sdk.pin_object.await?;
// Download
sdk.download.await?;
Key management
The AppKey grants full access to a user's data. After connecting, retrieve it with SDK::app_key(), then persist it using AppKey::export() and restore it with AppKey::import() so users don't need to re-approve on every launch.
License
This project is licensed under the MIT License.