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

Generics: Payload instead of Element? #4

Open
Fluci opened this issue Jun 27, 2017 · 0 comments
Open

Generics: Payload instead of Element? #4

Fluci opened this issue Jun 27, 2017 · 0 comments

Comments

@Fluci
Copy link
Owner

Fluci commented Jun 27, 2017

There might be an advantage in having a flexible payload. The same pattern as for Elements could be used (give key and value, let method decide how to store it).

If the payload builds its own elements, it could also decide from which struct type they are and hence only one parser would be needed for multi type elements.

What is the interface?

  • There could be a method, that creates an Element and returns it. The parser fills it as it is now and passes it back to the payload.
    • Not sure, how this interacts with rusts type system, returning structs of different types only conforming to a common trait seems tricky, it might not work, since the caller doesn't know how much stack space to allocate.
  • Instead returning the struct one might pass a mutable reference? This seems unsuitable, since the LinkedHashMap might not support this operation.
  • May be some kind of builder pattern?
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

No branches or pull requests

1 participant