10374af75c
On our way to v1.0.0 we are defining a standard for our error types, this includes: - Uses the following derives (unless not possible, usually because of `io::Error`) `#[derive(Debug, Clone, PartialEq, Eq)]` - Has `non_exhaustive` unless we really know we can commit to not adding anything. Furthermore, we are trying to make the codebase easy to read. Error code is write-once-read-many (well it should be) so if we make all the error code super uniform the users can flick to an error and quickly see what it includes. In an effort to achieve this I have made up a style and over recent times have change much of the error code to that new style, this PR audits _all_ error types in the code base and enforces the style, specifically: - Is layed out: definition, [impl block], Display impl, error::Error impl, From impls - `error::Error` impl matches on enum even if it returns `None` for all variants - Display/Error impls import enum variants locally - match uses *self and `ref e` - error::Error variants that return `Some` come first, `None` after Re: non_exhaustive To make dev and review easier I have added `non_exhaustive` to _every_ error type. We can then remove it error by error as we see fit. This is because it takes a bit of thinking to do and review where as this patch should not take much brain power to review. |
||
---|---|---|
.. | ||
contrib | ||
embedded | ||
extended_tests/schemars | ||
src | ||
CHANGELOG.md | ||
Cargo.toml | ||
README.md |
README.md
Bitcoin Hashes Library
This is a simple, no-dependency library which implements the hash functions needed by Bitcoin. These are SHA1, SHA256, SHA256d, SHA512, and RIPEMD160. As an ancilliary thing, it exposes hexadecimal serialization and deserialization, since these are needed to display hashes anway.
Minimum Supported Rust Version (MSRV)
This library should always compile with any combination of features on Rust 1.48.0.
To build with the MSRV you will need to pin serde
(if you have either the serde
or the
schemars
feature enabled)
# serde 1.0.157 uses syn 2.0 which requires edition 2021
cargo update -p serde --precise 1.0.156
before building. (And if your code is a library, your downstream users will need to run these commands, and so on.)
Contributions
Contributions are welcome, including additional hash function implementations.
Githooks
To assist devs in catching errors before running CI we provide some githooks. If you do not already have locally configured githooks you can use the ones in this repository by running, in the root directory of the repository:
git config --local core.hooksPath githooks/
Alternatively add symlinks in your .git/hooks
directory to any of the githooks we provide.
Running Benchmarks
We use a custom Rust compiler configuration conditional to guard the bench mark code. To run the
bench marks use: RUSTFLAGS='--cfg=bench' cargo +nightly bench
.