rust-vfs
rust-vfs copied to clipboard
no_std compatiblity
Hi!
I am looking for a generic file system abstraction which can possible be re-used with something like https://github.com/littlefs-project/littlefs / https://docs.rs/littlefs/latest/littlefs/ . My goal was to write components which depend on a generic file system abstraction which can be used on larger system like embedded Linux, but also on microcontroller which might not have a full run-time and use a custom or vendor-supplied filesystem.
Do you have any plans to add no_std support for your crate in the future? From what I have seen from the generic FS trait https://docs.rs/vfs/latest/vfs/filesystem/trait.FileSystem.html , alloc support is defnitely required, but there is also a dependency on std::io traits like Read and Write. These trait might move into core soon: https://github.com/rust-lang/rust/issues/48331 , but those traits not being in core is what probably makes this feature non-trivial right now..
Kind Regards Robin
Hi there, interesting use case! Missing Read and Write support in core would probably make the API quite awkward as of now.
But I'll look forward to exploring that possibility once these traits have landed in core. Alloc might be an issue, but maybe there is some creative solution to that as well.
I don't think Read and Write will be available in core anytime soon. For the time being, the acid_io crate might be a good alternative.
A first step could be compatibility with #[no_std] + alloc, which is a very common setup as well.
#[no_std] and alloc already sounds very good! I would say that most bare metal system where a file system is available in some shape or form also have sufficient heap for alloc support.
embedded_io provides Read and Write traits. And if the std feature is enabled, they automatically implement stdlib Read and Write traits. The crate is widely used in embedded systems.
Those traits are very useful, and I suppose it could be an option to add new trait similar to https://docs.rs/vfs/latest/vfs/filesystem/trait.FileSystem.html which uses the embedded_io traits instead..
Hmm, I am wondering what the best approach is here.
It might make sense to have rust-vfs define its own Read and Write traits, and have those blanket implement their counterparts in std or embedded_io if those dependencies/features are enabled.
This would decouple this crate from any dependencies, and be generic over possible dependencies.
Would that approach work for your use case?
According to crates.io statistics, embedded-io is more used than core-io and acid-io. I could personally choose embedded-io.
Also, it is maintained by an official team of Rust.