Crate ferro_storage

Crate ferro_storage 

Source
Expand description

§Ferro Storage

File storage abstraction for the Ferro framework.

Provides a unified API for working with different storage backends:

  • Local filesystem
  • In-memory (for testing)
  • Amazon S3 (with s3 feature)

§Example

use ferro_storage::{Storage, DiskConfig};

// Create storage with configuration
let storage = Storage::with_config(
    "local",
    vec![
        ("local", DiskConfig::local("storage/app")),
        ("public", DiskConfig::local("storage/public").with_url("/storage")),
    ],
);

// Store a file
storage.put("documents/report.pdf", file_contents).await?;

// Get a file
let contents = storage.get("documents/report.pdf").await?;

// Get URL
let url = storage.disk("public")?.url("images/logo.png").await?;

§Multiple Disks

You can configure multiple disks and switch between them:

use ferro_storage::Storage;

// Use specific disk
let disk = storage.disk("s3")?;
disk.put("backups/data.json", data).await?;

// Use default disk
storage.put("temp/cache.txt", cache_data).await?;

Structs§

Bytes
Re-export bytes for convenience. A cheaply cloneable and sliceable chunk of contiguous memory.
Disk
A handle to a specific disk.
DiskConfig
Storage disk configuration.
FileMetadata
File metadata.
LocalDriver
Local filesystem storage driver.
MemoryDriver
In-memory storage driver.
PutOptions
Options for storing files.
Storage
Storage facade for file operations.
StorageConfig
Configuration for the storage system.

Enums§

DiskDriver
Available disk drivers.
Error
Storage error types.
Visibility
Visibility of stored files.

Traits§

StorageDriver
Storage driver trait.

Attribute Macros§

async_trait
Re-export async_trait for implementing StorageDriver.