Closed VladYermakov closed 6 years ago
Correct, you are not allowed to implement erased_serde::Serialize. There is an impl<T: ?Sized> erased_serde::Serialize for T where T: serde::Serialize
so you need to provide a serde::Serialize impl and receive an automatic erased_serde::Serialize impl. The serialize_trait_object!
macro implements serde::Serialize for any trait object.
How to implement
erased_serde::Serialize
manually for custom type? The typesOk
andError
are private and this prevents to implementerased_serde::Serialize
for any type or trait outside the library. But if we can't implementserde::Serialize
we can't haveerased_serde::Serialize
for this type. E.g. for some traitTheTrait
we need type-erased serialize because if we implementserde::Serialize
we'll haveThe trait TheTrait cannot be made into an object
, but we can't implementerased_serde::Serialize
manually becauseOk
andError
ofResult
are private. Please provide any solution or makeOk
andError
types public.