mrhooray / crc-rs

Rust implementation of CRC(16, 32, 64) with support of various standards

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

wwylele opened this issue · comments

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.

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.

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

@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.

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

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.