rust-bitcoin-unsafe-fast/units
Martin Habovstiak b7689a7d60 Split up `ParseAmountError::InvalidFormat`
The `InvalidFormat` variant was pretty bad: it didn't make it clear what
exactly is wrong with the input string, especially since it was used
when the denomination was missing. Not only was this unhelpful to the
users who don't know they have to write the denomination when the amount
was otherwise correct but it was also attributed to a problem with the
amount rather than a problem with denomination.

To fix this the variant is replaced by `MissingDigitsError`,
`MissingError` and `InvalidCharError` - all the cases `InvalidFormat`
was originally used in.

`InvalidCharError` is effectively the same as the existing variant but
it was made into a separate error to enable special casing `.` and make
extensions possible. Further this opportunity was used to add a special
case for `-` as well.

`MissingDigitsError` currently contains special casing for empty string
and a string only containing minus sign. It's currently unclear if it's
useful so this change makes this distinction private and only makes it
affect error messages.

As opposed to the previous two variants, `MissingDenominationError` was
added to `ParseError`. The struct is currenly empty and may be extended
in the future with e.g. span information.
2024-02-24 08:55:32 +01:00
..
contrib CI: Epic overhaul 2024-02-02 05:57:23 +11:00
src Split up `ParseAmountError::InvalidFormat` 2024-02-24 08:55:32 +01:00
Cargo.toml Use InputString instead of String 2023-12-11 08:53:13 +11:00
README.md Add bitcoin-units crate 2023-12-11 08:52:31 +11:00

README.md

Bitcoin Units

This crate provides basic Bitcoin numeric units such as Amount.

Minimum Supported Rust Version (MSRV)

This library should always compile with any combination of features on Rust 1.56.1.

Licensing

The code in this project is licensed under the Creative Commons CC0 1.0 Universal license. We use the SPDX license list and SPDX IDs.