#local-filesystem #remi #logging #tracing #storage #async #local-storage

remi-fs

๐Ÿปโ€โ„๏ธ๐Ÿงถ Official and maintained remi-rs crate for support of the local filesystem

22 releases (8 breaking)

new 0.9.1 Oct 21, 2024
0.8.1 Oct 17, 2024
0.8.0 May 24, 2024
0.6.3 Feb 19, 2024
0.1.3 Feb 10, 2023

#2 in #remi

Download history 63/week @ 2024-06-30 43/week @ 2024-07-07 23/week @ 2024-07-14 31/week @ 2024-07-21 13/week @ 2024-07-28 10/week @ 2024-08-04 184/week @ 2024-08-11 230/week @ 2024-08-18 32/week @ 2024-08-25 9/week @ 2024-09-01 18/week @ 2024-09-08 238/week @ 2024-09-15 93/week @ 2024-09-22 107/week @ 2024-09-29 28/week @ 2024-10-06 303/week @ 2024-10-13

542 downloads per month

MIT license

65KB
815 lines

Official and maintained remi-rs crate for support of the local filesystem

v0.9.0 | ๐Ÿ“œ Documentation
Crate Features Description Enabled by default?
unstable Tap into unstable features from remi_fs and the remi crate. No.
serde_json Uses the serde_json crate to detect JSON documents and return application/json No.
serde_yaml_ng Allows to detect YAML documents with the serde_yaml_ng crate. No.
file-format Uses the file-format crate to find media types on any external datatype. Yes.
tracing Enables the use of tracing::instrument and emit events for actions by the crate. No.
infer Uses the infer crate to infer external datatypes and map them to their media type. Yes.
serde Enables the use of serde in StorageConfig No.
log Emits log records for actions by the crate No.

Example

// Cargo.toml:
//
// [dependencies]
// remi = "^0"
// remi-fs = "^0"
// tokio = { version = "^1", features = ["full"] }

use remi_fs::{StorageService, StorageConfig};
use remi::{StorageService as _, UploadRequest};

#[tokio::main]
async fn main() {
    // Initialize a `StorageService` that uses your local filesystem for storing files.
    let storage = StorageService::new("./data");

    // Next, we will run the `init` function which will create
    // the ./data directory if it doesn't exist already.
    storage.init().await.unwrap();

    // We define a `UploadRequest`, which will set the content type to `text/plain` and set the
    // contents of `weow.txt` to `weow fluff`.
    let upload = UploadRequest::default()
        .with_content_type(Some("text/plain"))
        .with_data("weow fluff");

    // Let's upload it!
    storage.upload("./weow.txt", upload).await.unwrap();

    // Let's check if it exists! This `assert!` will panic if it failed
    // to upload.
    assert!(storage.exists("./weow.txt").await.unwrap());
}

Dependencies

~3โ€“12MB
~137K SLoC