Comments (5)
(because different digest size).
When you derive a Mutlihash
via #[derive(Multihash)]
, all digests should have the same size. So at least that part should work (others may not ;)
from rust-multihash.
It is a bit confusing as both Hasher and StatefulHasher implement Default, but you are explicit about what you want Rust will give it to you.
let hasher: StatefulHasher = Identity256::default();
hopefully this works for you :)
from rust-multihash.
Hi π
Thank you for the answer, but this is not what Iβm looking for.
I need to get a hasher from a hash code I canβt know ahead of time (see my snippet above).
The issue is precisely that we canβt use StatefulHasher
except when using a specific algorithm known at compile-time like you mentioned, which kind of defeat the purpose of multihash to some extend :/
The new API is very nice when using digest
is acceptable though!
from rust-multihash.
I had a look. I currently see no way of doing it with the current code. The way things currently work, you cannot return a StatefulHasher
based on the Code
, as the StatefulHasher
s depend on specific Digest
s (please correct me if I'm wrong).
I've one idea though. Lots of the code is generated. So perhaps we could generate a companion struct to the Code
enum, which implements the StatefulHasher
functionality for all the Code
s. That struct would that returned by a Code::hasher()
call. I'm not sure if that would work, but it might be worth a try.
from rust-multihash.
I had a look. I currently see no way of doing it with the current code. The way things currently work, you cannot return a
StatefulHasher
based on theCode
, as theStatefulHasher
s depend on specificDigest
s (please correct me if I'm wrong).
Exact!
I've one idea though. Lots of the code is generated. So perhaps we could generate a companion struct to the
Code
enum, which implements theStatefulHasher
functionality for all theCode
s. That struct would that returned by aCode::hasher()
call. I'm not sure if that would work, but it might be worth a try.
This would be really helpful!
However, it might not be very straightforward because StatefulHasher
has associated types and implementing structs are using different types (because different digest size).
from rust-multihash.
Related Issues (20)
- Implement ripemd160 HOT 3
- CI tries to run `fmt` with unstable feature and will always fail HOT 2
- Nix build is currently broken HOT 3
- Maintain a CHANGELOG.md HOT 3
- Let's make fewer breaking changes HOT 14
- Replace or Upgrade Tarpaulin Code Coverage HOT 2
- Split crate into `multihash`, `multihash-codetable` and `multihash-derive` HOT 5
- Tracking issue: Polish and stabilize the API HOT 5
- Use `sha1` dependency instead of `sha-1`
- Unsafe unwrap could cause an application to panic HOT 12
- Consider removing `MultihashDigest` and `Hasher` traits
- Write docs for transition to new crate structure HOT 6
- Parity Codec bumps MSRV to `1.64.0` HOT 4
- Add `cargo semver-checks` to CI to ensure we don't break the API accidentially HOT 1
- Add Sha3 SHAKE* HOT 12
- Only enforce MSRV if no features are activated
- Release 0.19 HOT 8
- multihash const constructors unusable HOT 5
- Redesign multihash::Error
- regression serde feature does not work with no-std
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-multihash.