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

Differences between function and trait based operation #40

Closed
chrysn opened this issue Oct 2, 2018 · 2 comments
Closed

Differences between function and trait based operation #40

chrysn opened this issue Oct 2, 2018 · 2 comments

Comments

@chrysn
Copy link

chrysn commented Oct 2, 2018

Utilizing the crc crate with the crc64::Digest::new(crc64::ECMA) and core::Hasher interface, I was taken aback by the cost of it creating and allocating a table on the stack every time I start a new digest, which is prohibitive in an embedded environment.

The short-hand format checksum_ecma(...) is convenient only as long as data is available in a single run; I had to fall back to defining the field u64 and passing it through update, which is by far not as elegant as using the core::Hasher trait.

As I don't quite understand the reason for the different interfaces, I can make only uninformed suggestions on how the crate's behavior would be better suitable for my needs:

  • There could be a slimmer type wrapper around the intermediates that makes the static tables of update() available with a core::Hasher interface.
  • The Digest struct could become more general to allow building a Digest that uses the static tables.
  • The various two interfaces could be told apart in the README; right now the examples read as if checksum_x25 were just a shorthand for the later crc16::Digest::new(crc16::X25) with write and sum16, while actually it's doing vastly different things performance-wise.
@chrysn chrysn changed the title Differences between Differences between function and trait based operation Oct 4, 2018
@akhilles
Copy link
Collaborator

akhilles commented Sep 8, 2019

Please provide feedback on #48. It might address your use cases.

@chrysn
Copy link
Author

chrysn commented Sep 10, 2019

If v2 is accepted, this can be closed as "fixed by that".

chrysn added a commit to RIOT-OS/rust-riot-sys that referenced this issue May 31, 2022
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

3 participants