rust-bitcoin-unsafe-fast/internals
Martin Habovstiak 3e520f9094 Use hex from internals rather than hashes
`bitcoin-internals` contains a more performant implementation of hex
encoding than what `bitcoin_hashes` uses internally. This switches the
implementations for formatting trait implementations as a step towards
moving over completely.

The public macros are also changed to delegate to inner type which is
technically a breaking change but we will break the API anyway and the
consuers should only call the macro on the actual hash newtypes where
the inner types already have the appropriate implementations.

Apart from removing reliance on internal hex from public API this
reduces duplicated code generated and compiled. E.g. if you created 10
hash newtypes of SHA256 the formatting implementation would be
instantiated 11 times despite being the same.

To do all this some other changes were required to the hex
infrastructure. Mainly modifying `put_bytes` to accept iterator (so that
`iter().rev()` can be used) and adding a new `DisplayArray` type. The
iterator idea was invented by Tobin C. Harding, this commit just adds a
bound check and generalizes over `u8` and `&u8` returning iterators.

While it may seem that `DisplayByteSlice` would suffice it'd create and
initialize a large array even for small arrays wasting performance.
Knowing the exact length `DisplayArray` fixes this.

Another part of refactoring is changing from returning `impl Display` to
return `impl LowerHex + UpperHex`. This makes selecting casing less
annoying since the consumer no longer needs to import `Case` without
cluttering the API with convenience methods.
2022-12-22 10:44:27 +01:00
..
src Use hex from internals rather than hashes 2022-12-22 10:44:27 +01:00
CHANGELOG.md internals: Add CHANGELOG file 2022-11-08 08:40:44 +11:00
Cargo.toml Implement basic support for fast hex encoding 2022-09-13 22:17:31 +02:00
README.md Introduce bitcoin-internals crate 2022-09-13 08:59:57 +10:00
build.rs Activate `rust_v_1_46` when on high-enough rustc 2022-09-14 08:55:02 +02:00

README.md

Rust Bitcoin Internals

This crate is only meant to be used internally by crates in the rust-bitcoin ecosystem.

This crate will never be stabilized, depend on it at your own risk.