#vfs #embed #macro #compile-time #virtual-file-system

macro vfs-shadow

Effortlessly embed a local directory into a vfs

1 unstable release

0.1.0+0.12 Jan 14, 2025

#812 in Filesystem

Download history 46/week @ 2025-01-08 64/week @ 2025-01-15

110 downloads per month

MIT license

16KB
205 lines

vfs-shadow

Effortlessly embed a local directory into a vfs.


crates.io Version vfs Version License

About

vfs-shadow is a Rust crate that provides a macro, load_into_vfs!, which allows embedding a local directory into a virtual file system using the vfs crate.

Concept

vfs-shadow is designed to simplify the process of preparing a virtual file system in Rust. Using the load_into_vfs! macro, it allows you to embed a local directory directly into your binary at compile time. During runtime, the files and directories are automatically written into a virtual file system provided by the vfs crate, making them accessible as if they were part of the file system. This makes it easy to bundle assets or configuration files with your application without needing to manage them separately. By simply pointing to a directory in your project, you can include its contents into the virtual file system, streamlining the process of setting up a file system for your application.

Example

In the example/example.rs file, you can see how to use the macro to embed a directory into the virtual file system:

let fs = load_into_vfs!("example/vfs", MemoryFS::new()).unwrap();

This will include the example/vfs directory into the file system and use it with the MemoryFS implementation of the vfs crate.

Version Scheme

The version follows the format x.y.z+a.b:

  • x.y.z is the crate version.
  • a.b is the version of the vfs crate.

The patch version is ignored here, as upgrading it should not cause issues.

License

This crate is licensed under the MIT license. See the LICENSE file for more details.

Dependencies

~0.4–7MB
~52K SLoC