Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare release v0.1.0 #10

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Unreleased

- Rename `StableHasherResult` to `FromStableHash` (#8)
- Use new-type for returned-hash of `SipHasher128`(`Hash`) (#8)
- Introduce multi hasher support (#8)
- `StableHasher::finish` now returns a small hash instead of being fatal (#6)
- Remove `StableHasher::finalize` (#4)
# 0.1.0

- Rename `StableHasherResult` to `FromStableHash` [#8][pr8]
- Use new-type for returned-hash of `SipHasher128`(`Hash`) [#8][pr8]
- Introduce multi hasher support [#8][pr8]
- `StableHasher::finish` now returns a small hash instead of being fatal [#6][pr6]
- Remove `StableHasher::finalize` [#4][pr4]
- Import stable hasher implementation from rustc ([db8aca48129](/~https://github.com/rust-lang/rust/blob/db8aca48129d86b2623e3ac8cbcf2902d4d313ad/compiler/rustc_data_structures/src/))

[pr8]: /~https://github.com/rust-lang/rustc-stable-hash/pull/8
[pr6]: /~https://github.com/rust-lang/rustc-stable-hash/pull/6
[pr4]: /~https://github.com/rust-lang/rustc-stable-hash/pull/4
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
# rustc-stable-hash
A stable hashing algorithm used by rustc: cross-platform, deterministic, not secure

[![crates.io](https://img.shields.io/crates/v/rustc-stable-hash.svg)](https://crates.io/crates/rustc-stable-hash)
[![Documentation](https://docs.rs/rustc-stable-hash/badge.svg)](https://docs.rs/rustc-stable-hash)

A stable hashing algorithm used by `rustc`: cross-platform, deterministic, not secure.

This crate provides facilities with the `StableHasher` structure to create stable hashers over *unstable* hashers by abstracting over them the handling of endian-ness and the target `usize`/`isize` bit size difference.

Currently, this crate provides it's own implementation of 128-bit `SipHasher`: `SipHasher128`; with `StableSipHasher128` for the stable variant.

## Usage

```rust
use rustc_stable_hash::hashers::{StableSipHasher128, SipHasher128Hash};
use rustc_stable_hash::FromStableHash;
use std::hash::Hasher;

struct Hash128([u64; 2]);
impl FromStableHash for Hash128 {
type Hash = SipHasher128Hash;

fn from(SipHasher128Hash(hash): SipHasher128Hash) -> Hash128 {
Hash128(hash)
}
}

let mut hasher = StableSipHasher128::new();
hasher.write_usize(0xFA);

let hash: Hash128 = hasher.finish();
```