satsnet_units/
lib.rs

1// SPDX-License-Identifier: CC0-1.0
2
3//! Rust Bitcoin units library
4//!
5//! This library provides basic types used by the Rust Bitcoin ecosystem.
6
7// Experimental features we need.
8#![cfg_attr(docsrs, feature(doc_auto_cfg))]
9// Coding conventions.
10#![warn(missing_docs)]
11// Exclude lints we don't think are valuable.
12#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134
13#![allow(clippy::manual_range_contains)] // More readable than clippy's format.
14#![allow(clippy::needless_borrows_for_generic_args)] // https://github.com/rust-lang/rust-clippy/issues/12454
15#![no_std]
16
17// Disable 16-bit support at least for now as we can't guarantee it yet.
18#[cfg(target_pointer_width = "16")]
19compile_error!(
20    "rust-bitcoin currently only supports architectures with pointers wider than 16 bits, let us
21    know if you want 16-bit support. Note that we do NOT guarantee that we will implement it!"
22);
23
24#[cfg(feature = "alloc")]
25extern crate alloc;
26
27#[cfg(feature = "std")]
28extern crate std;
29
30/// A generic serialization/deserialization framework.
31#[cfg(feature = "serde")]
32pub extern crate serde;
33
34pub mod amount;
35#[cfg(feature = "alloc")]
36pub mod fee_rate;
37#[cfg(feature = "alloc")]
38pub mod locktime;
39#[cfg(feature = "alloc")]
40pub mod parse;
41#[cfg(feature = "alloc")]
42pub mod weight;
43
44pub use self::amount::ParseAmountError;
45#[doc(inline)]
46pub use self::amount::{Amount, SignedAmount};
47#[cfg(feature = "alloc")]
48pub use self::parse::ParseIntError;
49#[cfg(feature = "alloc")]
50#[doc(inline)]
51pub use self::{fee_rate::FeeRate, weight::Weight};
52
53#[rustfmt::skip]
54#[allow(unused_imports)]
55mod prelude {
56    #[cfg(all(feature = "alloc", not(feature = "std")))]
57    pub use alloc::{string::{String, ToString}, vec::Vec, boxed::Box, borrow::{Borrow, BorrowMut, Cow, ToOwned}, slice, rc};
58
59    #[cfg(feature = "std")]
60    pub use std::{string::{String, ToString}, vec::Vec, boxed::Box, borrow::{Borrow, BorrowMut, Cow, ToOwned}, rc};
61}