You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As it is now, you can't impl NewType on HexEncodedBytes as it doesn't impl ToHeader. That's not important though, imagine I want to make my API return HexEncodedBytes as a string like 0x32434. To get around this, I have to make 2 new structs: MyThingWrapper, MyOtherThingWrapper, and then a new newtype that for example encodes the Vec<u8> in some other way (a string, b64, etc). On top of that, I have to impl From<MyThingWrapper> for MyThing and all of the other types too.
As you can see, this ends up being a lot of additional wrapping code. Instead, what I'd like to do this this:
Okay I'm digging deeper into a better way to do this, and I'm currently impling Type, ParseFromJSON, etc. on my own for my types. This is working fairly well so far but the moment I get to a type I don't own, I struggle. This type is a newtype so I can't impl remote either. Perhaps including remote as part of the ask in #320 would be a solution to this part of the problem.
Hey, imagine I have code like this:
As it is now, you can't impl
NewType
onHexEncodedBytes
as it doesn't implToHeader
. That's not important though, imagine I want to make my API returnHexEncodedBytes
as a string like0x32434
. To get around this, I have to make 2 new structs:MyThingWrapper
,MyOtherThingWrapper
, and then a new newtype that for example encodes theVec<u8>
in some other way (a string, b64, etc). On top of that, I have toimpl From<MyThingWrapper> for MyThing
and all of the other types too.As you can see, this ends up being a lot of additional wrapping code. Instead, what I'd like to do this this:
Either that, or just pass in a serializer. With this, the spec should say that this field is a
String
, not aVec<u8>
.Is there some way we could add this feature?
Thanks!
The text was updated successfully, but these errors were encountered: