Add no `no_std` support
It would be possible to get the hasher module working if rand was swapped out for rand_chacha in GxBuildHasher and if it was given a constant seed in no_std environments.
const-random could be used, or the seed could be generated in the build script.
I got this working, generating the seed using the latter method here. I wanted to avoid drawing in more dependencies, and this actually reduces the number of dependencies, as rand depends on all of these.
Interesting, so if I understand correctly, with your changes, the Hasher remains even in no std builds, but with the following subtleties:
- When
stdfeature, it creates a seed using aChaCha12rng, that is itself seeded usinggetrandom(from OS) - When no
std- When possible,
getrandomwill userdrand - When not, hardcode a seed but a build time (so it's less dynamic, but still better than completely hardcoded seeds)
- When possible,
The author of ahash has done something similar, but making a separate crate for the build time random. Maybe we can reuse it to avoid the complexity introduced in build.rs
Nice! I have just cherry-picked your changes. Next step is to have this covered by tests/CI and add a few lines about it in the readme. I can do it when I have some time this week.
Hello! I'm sorry I haven't provided any update here. The no_std is still very relevant. Since there might be some changes regarding the Hasher construction and the dependencies, I've cherry-picked the first commit of this PR, even if the no_std removes the Hasher. This can be done as a second step once we have figured out what's best for the Hasher seeds generation.
https://github.com/ogxd/gxhash/pull/74