Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

0ndorio
Copy link
Contributor

@0ndorio 0ndorio commented Oct 3, 2020

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 #44 (comment). (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 😁

This will allow us to introduce the new StateTracker trait without
any name clashes.
Includes all methods exposed by the original StateTracker struct.
Allows to use non default `StateTracker` within a `Decoder`.
Also introduces strict versions of all `Decoder` related types.
@avdb13
Copy link

avdb13 commented Sep 2, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants