This repository was archived by the owner on Dec 19, 2020. It is now read-only.
This repository was archived by the owner on Dec 19, 2020. It is now read-only.
Things before upstreaming #5
Closed
Description
There are a few things I'd like to tackle before upstreaming. I put them into a single issue so that they can be discussed easily and we don't span this across zillions of issues or bloat PRs.
I split them into "ideas" which I think would make sense, but I'm, not sure about and "issues" which I think need to be fixed. Though they are all open for dicussions.
Ideas:
- Re-export all
generic_array::typenum::
asmultihash::sizes::
or so
Currently we only re-export some sized
Issues:
size()
should return the actual size. For most of the digests it's the same as the digest size. But it's not the case for the Identity hash.- This is connected to
digest()
should return the slice of the actual digest. This is again an issue for the Identity hash, where it should be trimmed tosize()
.
- This is connected to
- Implement
TryFrom
traits (and potentially remove the other functions from the traits (that's open for discussion):- For
from_bytes()
/to_bytes()
in the MultihashDigest - For
from_mh()
/to_mh()
inRawMultihash
- For
I've crated a list of things a Multihash implementation should implement and I think all those will be addressed. If I miss anything that should be supported (and perhaps already is by this library), please let me know:
-
An instance of a Multihash can be created in several ways:
- From an existing Multihash, represented as bytes.
- Also needs to support Multihashes that don't have an implementation. Such a Multihash wouldn't be able to create new hashed, but only be able to return
code
,size
anddigest
.
- Also needs to support Multihashes that don't have an implementation. Such a Multihash wouldn't be able to create new hashed, but only be able to return
- From an existing (non-Multihash) hash digest together with a Multihash Code. The size may either be given, calculated directly from the digest itself or implied (e.g. the type system).
- From data that still needs to get hashed together with a Multihash Code. The size may either be given or implied (e.g. the type system).
- From an existing Multihash, represented as bytes.
-
The Multihash instance then provides access to the properties of a hash:
code
: The code of the Multihash.size
: Thesize
needs to be the actual size. It may differ from the default hash size due to two reasons. Multihash supports trunctated hashes and there is also hash functions with arbitrary sizes, like Blake3.digest
: The actual hash.
Metadata
Metadata
Assignees
Labels
No labels