Skip to content
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

no_std compatiblity #38

Open
robamu opened this issue Nov 10, 2022 · 6 comments
Open

no_std compatiblity #38

robamu opened this issue Nov 10, 2022 · 6 comments

Comments

@robamu
Copy link

robamu commented Nov 10, 2022

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: rust-lang/rust#48331 , but those traits not being in core is what probably makes this feature non-trivial right now..

Kind Regards
Robin

@manuel-woelker
Copy link
Owner

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.

@robertbastian
Copy link

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.

@robamu
Copy link
Author

robamu commented Aug 4, 2023

#[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.

@orsinium
Copy link

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.

@robamu
Copy link
Author

robamu commented May 28, 2024

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..

@manuel-woelker
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants