Replies: 1 comment 1 reply
-
|
I think I solved it, don't really understand it completely, but it seems to work: In the SDCard module I defined: pub type SDCardStoreErrorType = Error<embedded_sdmmc::asynchronous::SdCardError>;that's in addition to what I already had: pub type SdCardError<SPI> = <SdCard<SPI, embassy_time::Delay> as BlockDevice>::Error;
pub type SDCardStoreError<SPI> = Error<SdCardError<SPI>>;In the CsvDb I used the error: #[derive(Snafu, Debug)]
pub enum CsvDbError
{
#[snafu(display("Failed to open volume"))]
Store {
source: SDCardStoreErrorType,
},
}And now |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm developing in no_std on an embedded device and trying to use Snafu.
With @shepmaster assistance (#493) I managed to get one module working (with DebugWrap).
But I couldn't get the module using that Error to create its own Error with the first one as source.
At high level I want to develop a simple csv-db using sdcard.
Below is the code I ended up with for the first module (the SDCard) - which honestly, I don't fully understand, but its working.
The SDCard module uses an underlying module who's error is generic over the Error of block device which is generic over Spi Device (I hope I got it right)
With that, now I want to implement my CsvDb which will have as source the SDCardStoreError, but bottom line all my trials failed.
My understanding is that now my SDCardStoreError implements the Error trait because it is generated by Snafu.
So I tried:
And on the context usage the compiler throws an error:
Probably because the compiler doen't know that SPI will not need to be formatted, only it's Error will need to, but it doen't know it here.
I tried all kinds of other options but just couldn't get it to work the way I wanted to.
Maybe too mainy constraints driven by no_std and patterns there, but before I turn to String based errors, I post here the question how can I make it work?
Beta Was this translation helpful? Give feedback.
All reactions