bendy icon indicating copy to clipboard operation
bendy copied to clipboard

[Draft] Parameterize decode and encode related structs and traits with `StateTracker`

Open 0ndorio opened this issue 5 years ago • 1 comments

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 StrictTracker implementation.

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 use StrictByteTracker to avoid that all of the existing FromBencode implementations 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:

0ndorio avatar Oct 03 '20 10:10 0ndorio

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.

avdb13 avatar Sep 02 '23 12:09 avdb13