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

Consider making capacity async #37

Open
diondokter opened this issue May 9, 2023 · 2 comments · May be fixed by #54
Open

Consider making capacity async #37

diondokter opened this issue May 9, 2023 · 2 comments · May be fixed by #54

Comments

@diondokter
Copy link
Contributor

diondokter commented May 9, 2023

The function capacity on the async ReadNotFlash trait is not async: https://github.com/rust-embedded-community/embedded-storage/blob/master/embedded-storage-async/src/nor_flash.rs#L18

I'm trying to make a shared flash based on these traits and to do that I have an async mutex that needs to be locked. But I can't do that in a sync function.

It would also be solved by having the capacity be a constant. But there may be a good reason why it's not a constant already

@avsaase
Copy link

avsaase commented Jul 19, 2024

I'm implementing ReadNorFlash for an SD card driver (I know it's weird) and I'm running into the same issue. Getting the SD card size is an async operation but I cannot await the future because capacity is not async.

@MathiasKoch
Copy link
Collaborator

I would be fine with making capacity async for situations like this, and also JEDEC like NorFlash implementations.
I do however think that if we make it async, it should also be fallible, as that would usually incur some kind of IO operations?

Another way of solving this would be to probe for the capacity at initialization of the module (Flash or SD card), and store the size as part of the driver struct in a simple usize.

@avsaase avsaase linked a pull request Jul 19, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants