Hi, I have a small problem with certain types when I want to put them in a Message. For example, my application uses sqlx for database connections. Because sqlx is async, the tasks can be submitted to the async runtime using an
iced::Command. I want to handle possible sqlx errors in my application, so a Message could look like this:
Message::QueryResponse(Result<MyData, sqlx::Error>). But this does not work, because
Message is required to implement
Clone + Debug and
sqlx::Error does not implement
For non-Debug types it would be easy. I could simply wrap them in a Newtype and implement Debug myself and then destructure it in the match expression.
A workaround I’ve used is to wrap the
Result in an
Option is there so I can get ownership of the value with
Option::take() and not only a mutable reference). But this not the most ergonomic thing to use and is quite messy.
Is there a cleaner way to achieve this? I’ve seen the pokédex example, where the
reqwest::Error is converted to a Clone-able type, but you lose all the information from reqwest.