Make the error returned by the BytesDecode/BytesEncode trait customizable#166
Make the error returned by the BytesDecode/BytesEncode trait customizable#166irevoire wants to merge 3 commits into
Conversation
|
I tried to introduce more variants to the Unfortunately, it's not that easy to convert the generic |
Instead of adding two variants to the enum, a new enum can be made that can hold two (different) encoding errors (or use a crate like I came up with this here. |
This PR is an attempt at getting rid of the
BoxedErrortype we currently use everywhere.That allows us to use a « real » type when an error arises in the
BytesEncodeorBytesDecodetraits.The new traits
I called the type
Errto do something similar to theFromStrtrait from the stdlib.The new
ErrorenumI had to make the
Errorenum generic over the decoding and encoding error.For most functions, that do not add any complexity because we use our
Resulttype;That set
EandDtoInfallibleby default.My issue
For some methods like the following one, we can return an error while encoding the key OR the value + while decoding the key OR the value:
One solution could be adding two other variants to the
Errorenum.