I'm sorry if this may be a duplicate, but I've gone down a bit of a rabbit hole trying to get this to work.
I have a trait Subscriber which I need to use as a trait object (Box<dyn Subscriber>), but I also require that it implements Serialize + DeserializeOwned from serde.
I've tried adding where Self: erased_serde::Serialize, though it seems like this crate doesn't provide a Deserialize trait?
So I attempted to implement it manually:
impl<'de> Deserialize<'de> for Box<dyn Subscriber> {
// ...
}
Though I'm not sure what I could put for the implementation.
I'm sorry if this may be a duplicate, but I've gone down a bit of a rabbit hole trying to get this to work.
I have a trait
Subscriber
which I need to use as a trait object (Box<dyn Subscriber>
), but I also require that it implementsSerialize + DeserializeOwned
from serde.I've tried adding
where Self: erased_serde::Serialize
, though it seems like this crate doesn't provide aDeserialize
trait? So I attempted to implement it manually:Though I'm not sure what I could put for the implementation.
After struggling, I came across the
typetag
crate, but sadly my target is wasm and I am having issues withctor
: https://github.com/mmastrac/rust-ctor/issues/14