monofs
is a versioned content-addressed filesystem designed for distributed applications. It is based largely on the WNFS public filesystem.
Warning
This project is in early development and is not yet ready for production use.
- 🔄 Automatic Deduplication: Save storage space by storing identical content only once, even across different files and directories
- 🔒 Versioned: Every change creates a new version, making it impossible to accidentally lose data
- 🌐 Built for Distribution: Perfect for peer-to-peer and decentralized applications with content-addressed storage
- ⚡ Efficient Syncing: Only transfer what's changed between versions, saving bandwidth and time
- 🛡️ Data Integrity: Content addressing ensures data hasn't been tampered with or corrupted
curl -sSfL https://get.monofs.dev | sh
TODO: Demo of running multiple servers on different paths syncing up with each other and use with monocore.
use monofs::filesystem::File;
use ipldstore::MemoryStore;
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 = file.get_output_stream();
output_stream.write_all(b"Hello, monofs!").await?;
output_stream.shutdown().await?;
// Read content from the file
let mut input_stream = file.get_input_stream().await?;
let mut buffer = Vec::new();
input_stream.read_to_end(&mut buffer).await?;
println!("File content: {}", String::from_utf8_lossy(&buffer));
// Drop reader to free up reference to the file
drop(input_stream);
// Persist changes; creates a new version of the file
let file_cid = file.checkpoint().await?;
println!("Checkpoint file with CID: {}", file_cid);
Ok(())
}
use monofs::filesystem::{Dir, FsResult};
use ipldstore::MemoryStore;
#[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.create_file("example.txt").await?;
// Create a subdirectory
root.create_dir("subdir").await?;
// List directory contents
for (name, entity) in root.get_entries() {
println!("- {}: {:?}", name, entity);
}
// Persist changes; creates a new version of the directory
let root_cid = root.checkpoint().await?;
println!("Checkpoint 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 store
For more detailed examples and API usage, check out the examples
directory and the API documentation.
To set up monofs
for development:
- Ensure you have Rust installed (latest stable version)
- Clone the monocore repository:
git clone https://github.com/appcypher/monocore cd monocore/monofs
- Build the project:
cargo build
- Run tests:
cargo test
This project is licensed under the Apache License 2.0.