[Draft] Parameterize decode and encode related structs and traits with `StateTracker`
Right now this draft only parameterizes the decoding part to ensure the given structure matches the expectations of @thequux. I am going to implement the encoding part as soon as the decoder got reviewed.
This is the second of three pull requests to introduce relaxed StateTracker implementation as @thequux supposed in https://github.com/P3KI/bendy/issues/44#issuecomment-678833957. (The changeset also still includes more changes as necessary as its based on the not yet merged pull request #46).
Included Changes:
- Introduce generic parameter for almost any structs in
crate::decoding. - Setup and export type definitions based on the existing
StrictTrackerimplementation.
Questions:
- Should this export both versions (generic and strict) or only the strict version to reduce the amount of breaking changes?
- What about the definition of
FromBencode? Right now it is limited to useStrictByteTrackerto avoid that all of the existingFromBencodeimplementations must be updated. Is this the expected behavior? Should we also introduce a generic version of this trait?
Feel free to nitpick as much as possible :grin:
I think the right approach is gonna be to embed a trait constant as a flag in the trait definition so the user can decide whether he wants to do strict or relaxed tracking.