remotefs-memory 1.0.0

remotefs implementation for volatile memory. Good for testing and simulation.
Documentation

remotefs-memory


Getting Started

Add remotefs-memory to your Cargo.toml:

remotefs = "1"
remotefs-memory = "1"

MemoryFs implements the blocking remotefs::RemoteFs trait from remotefs 1. Every path is absolute and the tree root is /; there is no working directory. Transfers return owned streams that must be finished. Async consumers can wrap the client in remotefs::adapters::r#async::Unblock (remotefs tokio feature).

Example

use std::io::Write;
use std::path::{Path, PathBuf};

use remotefs_memory::{Inode, MemoryFs, node, Node, Tree};
use remotefs::RemoteFs;
use remotefs::fs::{ReadOptions, UnixPex, WriteOptions};

let tempdir = PathBuf::from("/tmp");
let tree = Tree::new(node!(
    PathBuf::from("/"),
    Inode::dir(0, 0, UnixPex::from(0o755)),
    node!(tempdir.clone(), Inode::dir(0, 0, UnixPex::from(0o755)))
));
let mut client = MemoryFs::new(tree);
client.connect().unwrap();

let mut stream = client
    .create(Path::new("/tmp/hello.txt"), &WriteOptions::default())
    .unwrap();
stream.write_all(b"hello").unwrap();
stream.finish().unwrap();

let mut output = Vec::new();
client
    .read_file(
        Path::new("/tmp/hello.txt"),
        &ReadOptions::default(),
        &mut output,
    )
    .unwrap();
assert_eq!(output, b"hello");

Contributing 🤝

Contributions, bug reports, new features, and questions are welcome! 😉 If you have any questions or concerns, or you want to suggest a new feature, or you want just want to improve remotefs, feel free to open an issue or a PR.

Please read the AI policy before opening a pull request.


Changelog ⏳

View remotefs` changelog HERE


License 📃

remotefs is licensed under the MIT license.

You can read the entire license HERE