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

Remove lifetime parameter from Protocol #6

Open
jminer opened this issue Nov 8, 2016 · 0 comments
Open

Remove lifetime parameter from Protocol #6

jminer opened this issue Nov 8, 2016 · 0 comments

Comments

@jminer
Copy link
Owner

jminer commented Nov 8, 2016

I'm not sure yet, but I'm leaning towards removing the lifetime parameter from Protocol. Lifetime parameter pro/cons:

Pros:

  • Reduces the number of allocations the parser does. All identifiers (of records, fields, messages, parameters, etc.) can just be slices.

Cons:

  • Since identifiers are just slices of the input, then the input needs to live longer than the slices. The IDL file contents has to be kept around as long as the protocol is used because the protocol borrows it. This could be annoying in some apps. This could be solved at the expense of adding a Protocol.to_static method that returns Protocol<'static>.
  • Adding another lifetime parameter to whatever contains a reference to a protocol can get very annoying too.

Basically, the pro is performance and the con is ergonomics. I'm not convinced that IDL file parsing speed matters a lot. Most of Rust's JSON and XML libraries make it hard or impossible to do zero-copy parsing, and I think it matters a lot more for them.

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