Closed tareknaser closed 4 months ago
Take a look at https://github.com/ARK-Builders/arklib/tree/blake3_ResourceIdTrait. It shows how easy it is to include a new ResourceId
type that implements ResourceIdTrait
, featuring Blake3 as the hash function in this instance.
Also notice that ResourceIndex
still has collision tracking although blake3 is a cryptographic hash function and there should be no collisions.
Description
This PR aims to make
ResourceIndex
type generic over the hash function used to generate resource identifiersResolves #75
Changes
ResourceIdTrait
. This trait defines a set of functions and requirements that all specificResourceId
implementations must implementResourceIdTrait
, a type alias namedHashType
is defined. This allows differentResourceId
implementations to use different types for their hash values, but we ensure that allHashType
types implement specific traits for consistent behaviorResourceIdCrc32
type to implement theResourceIdTrait
Future work
src/index.rs
file heavily relies on the assumption of only usingResourceIdCrc32
. It will require adjustments, potentially including abstracting some tests, to function with variousResourceId
types.ResourceIdBlake3
that implementsResourceIdTrait
src/resource
directory into a separate crate for better organization.