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

Crc::new doesn't need to require a 'static Algorithm reference #68

Open
wwylele opened this issue Jan 29, 2022 · 5 comments
Open

Crc::new doesn't need to require a 'static Algorithm reference #68

wwylele opened this issue Jan 29, 2022 · 5 comments

Comments

@wwylele
Copy link

wwylele commented Jan 29, 2022

This restricts how a program could construct a custom algorithm locally ands use it on the fly.

I noticed that the current internal of Crc holds the reference. Relaxing the lifetime means Crc would need a lifetime parameter as well, which is a breaking change unfortunately. An alternative way is to let Crc clone the data Algorithm has.

@akhilles
Copy link
Collaborator

akhilles commented Apr 8, 2022

Would #69 be sufficient for this? I can't really think of a use case where parameters other than init have to be generated dynamically.

@wwylele
Copy link
Author

wwylele commented Apr 8, 2022

I think originally when I opened this issue, I was trying to bruteforce an unknown CRC algorithm given data and the end result. In that case, every parameter can be unknown and needs to be constructed on the fly.

But I agree that the init value is the most useful one to allow customizing

@nathanaelg
Copy link

nathanaelg commented Aug 3, 2022

@wwylele Did you find a way of doing it? I have a fairly similar use case. I also wasn't really sure how to get around passing in check and residue if you're cycling through and don't have those values pre calculated.

@wwylele
Copy link
Author

wwylele commented Aug 3, 2022

@nathanaelg No, I didn't. I didn't finish that project for other reasons.

@akhilles
Copy link
Collaborator

akhilles commented Aug 4, 2022

If the list of possible algorithms is bounded, then could you create a const array of all the ones you want to test? Maybe with a const fn.

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