Crates.io | monofs |
lib.rs | monofs |
version | |
source | src |
created_at | 2024-12-04 14:55:49.359847 |
updated_at | 2024-12-11 15:26:28.529268 |
description | `monofs` is an immutable distributed file system. |
homepage | |
repository | https://github.com/appcypher/monocore |
max_upload_size | |
id | 1472170 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
monofs
is a powerful, distributed filesystem designed for distributed workloads. It provides a simple and intuitive API for managing files and directories in a content-addressed storage system.
[!WARNING] This project is in early development and is not yet ready for production use.
Here are some examples of how to use the monofs
API:
use monofs::filesystem::{File, FileInputStream, FileOutputStream};
use monoutils_store::{MemoryStore, Storable};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let store = MemoryStore::default();
// Create a new file
let mut file = File::new(store.clone());
// Write content to the file
let mut output_stream = FileOutputStream::new(&mut file);
output_stream.write_all(b"Hello, monofs!").await?;
output_stream.shutdown().await?;
// Read content from the file
let input_stream = FileInputStream::new(&file).await?;
let mut buffer = Vec::new();
input_stream.read_to_end(&mut buffer).await?;
println!("File content: {}", String::from_utf8_lossy(&buffer));
// Store the file
let file_cid = file.store().await?;
println!("Stored file with CID: {}", file_cid);
Ok(())
}
use monofs::filesystem::{Dir, File, FsResult};
use monoutils_store::{MemoryStore, Storable};
#[tokio::main]
async fn main() -> FsResult<()> {
let store = MemoryStore::default();
// Create a new root directory
let mut root = Dir::new(store.clone());
// Create a file in the directory
root.put_file("example.txt", File::new(store.clone()))?;
// Create a subdirectory
root.put_dir("subdir", Dir::new(store.clone()))?;
// List directory contents
for (name, entity) in root.get_entries() {
println!("- {}: {:?}", name, entity);
}
// Store the directory
let root_cid = root.store().await?;
println!("Stored root directory with CID: {}", root_cid);
Ok(())
}
File
: Represents a file in the filesystemDir
: Represents a directory in the filesystemFileInputStream
: Provides read access to file contentsFileOutputStream
: Provides write access to file contentsMetadata
: Stores metadata for files and directoriesStorable
: Trait for storing and loading entities from the content-addressed storeFor more detailed examples and API usage, check out the examples
directory and the API documentation.
To set up monofs
for development:
git clone https://github.com/appcypher/monocore
cd monocore/monofs
cargo build
cargo test
Contributions are welcome! Please read the CONTRIBUTING.md file for guidelines on how to contribute to this project.
This project is licensed under the Apache License 2.0.
monofs draws inspiration from the WNFS (Webnative File System) project.