Closed jakoschiko closed 11 months ago
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
imap-codec/src/codec.rs | 6 | 12 | 50.0% | ||
<!-- | Total: | 29 | 35 | 82.86% | --> |
Totals | |
---|---|
Change from base Build 5796696502: | -0.06% |
Covered Lines: | 8706 |
Relevant Lines: | 9302 |
This makes so much more sense, thanks! :+1: (As discussed offline, let's talk about how, and when, to merge this later.)
As discussed yesterday, I moved the *Decoder
structs into codec
and renamed them to *Codec
. As you proposed, I also removed the StaticDecoder
by making it a default trait impl. Is there anything left we want to do in this PR?
Two possible paths to continue: 1) Continue with Encoder
or 2) #333.
I suggest this order: merge this, merge #333, add Encoder
Replaces the current trait
Decode
with the traitDecoder
in order to improve lifetime issues.I don't expect this PR to be merged, I just want to demonstrate my ideas. So, what's the problem with the current trait
Decode
?If I use this trait with type bounds, then I need to choose the lifetime in the wrong place:
This prevents me from writing useful abstractions based on
Decode
. So, here my proposed traitDecoder
.It allows me to choose the lifetime at a later point in time:
List of changes:
Decode
withDecoder
CommandDecoder
,ResponseDecoder
, etc. that implementDecoder
DecodeStatic
withStaticDecoder
that I was able to implement with less code duplicationDecode
If you like the changes, we could do even more:
Encode
withEncoder
CommandDecoder
,ResponseDecoder
, etc. withCommandCodec
,ResponseCodec
, etc. that implement bothDecoder
andEncoder