#virtual-filesystem #facade #rivia

rivia-vfs

Ergonomic facade for the Rivia Virtual FileSystem

9 releases

0.2.6 Jul 1, 2024
0.2.5 Apr 4, 2022
0.2.4 Mar 7, 2022
0.1.5 Mar 5, 2022
0.0.1 Nov 20, 2021

#175 in Filesystem

Download history 64/week @ 2024-07-30 10/week @ 2024-09-10 7/week @ 2024-09-17 19/week @ 2024-09-24 6/week @ 2024-10-01

548 downloads per month

MIT/Apache

82KB
894 lines

rivia-vfs

license-badge build codecov crates.io Minimum rustc

Ergonomic facade for the Rivia Virtual FileSystem

Usage

  1. Import the crate
    [dependencies]
    rivia-vfs = "0.2.6"
    
  2. Use the crate
    use rivia_vfs::prelude::*;
    
    fn main() {
        // Simply remove this line to default to the real filesystem.
        vfs::set_memfs().unwrap();
    
        let config = load_config();
        assert_eq!(config, "this is a test");
        println!("VFS test passed");
    }
    
    // Load an example application configuration file using VFS.
    // This allows you to test with a memory backed VFS implementation during testing and with
    // the real filesystem during production.
    fn load_config() -> String {
        let dir = PathBuf::from("/etc/xdg");
        vfs::mkdir_p(&dir).unwrap();
        let filepath = dir.mash("rivia.toml");
        vfs::write_all(&filepath, "this is a test").unwrap();
        assert_eq!(vfs::config_dir("rivia.toml").unwrap().to_str().unwrap(), "/etc/xdg");
    
        if let Some(config_dir) = vfs::config_dir("rivia.toml") {
            let path = config_dir.mash("rivia.toml");
            return vfs::read_all(&path).unwrap();
        }
        "".into()
    }
    

Rustc requirements

This minimum rustc requirement is driven by the enhancements made to Rust's std::error::Error handling improvements

Contribute

Pull requests are always welcome. However understand that they will be evaluated purely on whether or not the change fits with my goals/ideals for the project.

Project guidelines:

  • Chaining - ensure Rust's functional chaining style isn't impeded by additions
  • Brevity - keep the naming as concise as possible while not infringing on clarity
  • Clarity - keep the naming as unambiguous as possible while not infringing on brevity
  • Performance - keep convenience functions as performant as possible while calling out significant costs
  • Speed - provide ergonomic functions similar to rapid development languages
  • Comfort - use naming and concepts in similar ways to popular languages

Dev Environment

Automatic version

Enable the git hooks to have the version automatically incremented on commits

cd ~/Projects/rivia-vfs
git config core.hooksPath .githooks

Testing

Test in container

TBD

License

This project is licensed under either of:

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, shall be dual licensed as above, without any additional terms or conditions.


Backlog

Changelog

Dependencies

~3MB
~54K SLoC