Commit Graph

2 Commits

Author SHA1 Message Date
Tobin C. Harding dedae8acf2
Implement custom serde modules for FeeRate
The `FeeRate` type wraps a `u64` but the inner value implicitly contains
information about the unit. As such when serializing and deserializing
the unit information is not explicit and if users try to deserialize
with a different unit their code will be silently buggy.

As we do for Amount; add custom serde modules so that users can
serialize in an explicit unit. Furthermore remove the derived impls
forcing users to make the decision. This is as we do for `Amount`.

With this applied one can write

```rust
    #[derive(Serialize, Deserialize)]
    pub struct Foo {
        #[serde(with = "bitcoin_units::fee_rate::serde::as_sat_per_kwu")]
        pub fee_rate: FeeRate,
    }
```
2024-12-28 08:15:13 +11:00
Tobin C. Harding d94e5f03e6
Move fee_rate.rs to module
In preparation for adding `serde` modules to the `fee_rate` module
create a sub directory.

Create a directory and move `fee_rate.rs` to `fee_rate/mod.rs`.
2024-12-28 08:02:52 +11:00
Renamed from units/src/fee_rate.rs (Browse further)