-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a read only embedded FileSystem implementation backed by rust-embed #12
Conversation
@@ -9,4 +9,5 @@ matrix: | |||
allow_failures: | |||
- rust: nightly | |||
- rust: beta | |||
script: cargo build --verbose && cargo test --verbose | |||
script: cargo build --verbose && cargo test --verbose && | |||
cargo build --verbose --all-features && cargo test --verbose --all-features |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to show the tests pass, not sure what approach you want to take for this.
@@ -14,7 +14,11 @@ travis-ci = { repository = "manuel-woelker/rust-vfs", branch = "master" } | |||
|
|||
[dependencies] | |||
thiserror = "1.0" | |||
rust-embed = { version = "5.6", optional = true } | |||
radix_trie = { version = "0.1", optional = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentionally old version to support 1.32.0, the most recent version supports 1.36.0 due to a transient dependency on smallvec.
fn child_elements<'a>( | ||
d: &'a Path, | ||
t: SubTrie<'a, String, bool>, | ||
) -> Box<dyn Iterator<Item = String> + 'a> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If performance turns out to be an issue the dynamic iterator here could be replaced with an enum where each variant is one of the concrete types below.
Thanks for the PR! Should be great for fully self-contained executables. I imagine in some cases all the paths accessed in the embedded FS are known by the application anyway, so read_dir() and the supporting trie might not even be needed. |
Adds a read only embedded
FileSystem
implementation backed by rust-embed.The API of rust-embed is very simplistic, so if we were to implement
FileSystem.read_dir
without some kind of cache we would have to iterate through the entire directory listing every time. To prevent this I chose to use a radix trie to store the paths of files and directories whenEmbeddedFs
is constructed.Both added dependencies are optional and gated behind a feature flag, so users who do not explicitly ask for embedded file system support will not need to download/compile them.