Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
fix: do not enforce get_hash for implementors of ResourceIdTrait
Browse files Browse the repository at this point in the history
Signed-off-by: Tarek <tareknaser360@gmail.com>
  • Loading branch information
tareknaser committed Mar 18, 2024
1 parent 4e293ee commit 4617c88
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
8 changes: 2 additions & 6 deletions src/resource/crc32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ impl FromStr for ResourceId {
impl ResourceIdTrait<'_> for ResourceId {
type HashType = u32;

fn get_hash(&self) -> Self::HashType {
self.hash
}

fn compute<P: AsRef<Path>>(data_size: u64, file_path: P) -> Result<Self> {
log::trace!(
"[compute] file {} with size {} mb",
Expand Down Expand Up @@ -140,12 +136,12 @@ mod tests {
.len();

let id1 = ResourceId::compute(data_size, file_path).unwrap();
assert_eq!(id1.get_hash(), 0x342a3d4a);
assert_eq!(id1.hash, 0x342a3d4a);
assert_eq!(id1.data_size, 128760);

let raw_bytes = fs::read(file_path).unwrap();
let id2 = ResourceId::compute_bytes(raw_bytes.as_slice()).unwrap();
assert_eq!(id2.get_hash(), 0x342a3d4a);
assert_eq!(id2.hash, 0x342a3d4a);
assert_eq!(id2.data_size, 128760);
}

Expand Down
3 changes: 0 additions & 3 deletions src/resource/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ pub trait ResourceIdTrait<'de>:
/// Associated type representing the hash used by this resource identifier.
type HashType;

/// Returns the hash value of the resource.
fn get_hash(&self) -> Self::HashType;

/// Creates a new resource identifier from the given path.
///
/// # Arguments
Expand Down

0 comments on commit 4617c88

Please sign in to comment.