Inline io module in io crate root

Its not immediately obvious why we nest the whole `io` code in an `io`
submodule within `lib.rs`. As far as I can tell we can inline it and
re-export from `rust-bitcoin` same as we do for our other dependencies.

This change would effect other users of the crate but since the `io`
crate is unreleased this effects no-one except us.
This commit is contained in:
Tobin C. Harding 2023-11-28 11:49:26 +11:00
parent 80fe9b99b2
commit 5c0759a390
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
6 changed files with 333 additions and 333 deletions

View File

@ -27,8 +27,8 @@ bitcoinconsensus-std = ["bitcoinconsensus/std", "std"]
# The no-std feature doesn't disable std - you need to turn off the std feature for that by disabling default.
# Instead no-std enables additional features required for this crate to be usable without std.
# As a result, both can be enabled without conflict.
std = ["secp256k1/std", "bitcoin-io/std", "hashes/std", "bech32/std", "internals/std", "hex/std"]
no-std = ["hashes/alloc", "hashes/io", "bitcoin-io/alloc", "bech32/alloc", "secp256k1/alloc", "hex/alloc"]
std = ["secp256k1/std", "io/std", "hashes/std", "bech32/std", "internals/std", "hex/std"]
no-std = ["hashes/alloc", "hashes/io", "io/alloc", "bech32/alloc", "secp256k1/alloc", "hex/alloc"]
[package.metadata.docs.rs]
all-features = true
@ -40,10 +40,9 @@ hex = { package = "hex-conservative", version = "0.1.1", default-features = fals
bech32 = { version = "0.10.0-beta", default-features = false }
hashes = { package = "bitcoin_hashes", version = "0.13.0", default-features = false }
secp256k1 = { version = "0.28.0", default-features = false, features = ["hashes"] }
io = { package = "bitcoin-io", version = "0.1", default-features = false }
hex_lit = "0.1.1"
bitcoin-io = { version = "0.1", default-features = false }
base64 = { version = "0.21.3", optional = true }
# Only use this feature for no-std builds, otherwise use bitcoinconsensus-std.
bitcoinconsensus = { version = "0.20.2-0.5.0", default-features = false, optional = true }

View File

@ -74,6 +74,9 @@ pub extern crate hashes;
/// Re-export the `hex-conservative` crate.
pub extern crate hex;
/// Re-export the `bitcoin-io` crate.
pub extern crate io;
/// Rust wrapper library for Pieter Wuille's libsecp256k1. Implements ECDSA and BIP 340 signatures
/// for the SECG elliptic curve group secp256k1 and related utilities.
pub extern crate secp256k1;
@ -113,7 +116,6 @@ pub mod sign_message;
pub mod string;
pub mod taproot;
use bitcoin_io::io;
#[rustfmt::skip] // Keep public re-exports separate.
#[doc(inline)]

View File

@ -10,7 +10,7 @@ extern crate bitcoin_hashes;
#[cfg(feature = "alloc")] use alloc::string::ToString;
use bitcoin_hashes::{sha256, Hash, HashEngine};
use bitcoin_io::io::Write;
use bitcoin_io::Write;
use core::str::FromStr;
use cortex_m_rt::entry;
use cortex_m_semihosting::{debug, hprintln};

View File

@ -66,7 +66,7 @@ impl_write!(
#[cfg(test)]
mod tests {
use bitcoin_io::io::Write;
use bitcoin_io::Write;
use crate::{hash160, hmac, ripemd160, sha1, sha256, sha256d, sha512, siphash24, Hash};

View File

@ -24,7 +24,6 @@ mod macros;
/// Standard I/O stream definitions which are API-equivalent to `std`'s `io` module. See
/// [`std::io`] for more info.
pub mod io {
#[cfg(any(feature = "alloc", feature = "std"))]
use alloc::boxed::Box;
use core::convert::TryInto;
@ -351,4 +350,4 @@ pub mod io {
}
/// Returns a sink to which all writes succeed. See [`std::io::sink`] for more info.
pub fn sink() -> Sink { Sink }
}

View File

@ -11,13 +11,13 @@
#[cfg(not(feature = "std"))]
macro_rules! impl_write {
($ty: ty, $write_fn: expr, $flush_fn: expr $(, $bounded_ty: ident : $bounds: path),*) => {
impl<$($bounded_ty: $bounds),*> $crate::io::Write for $ty {
impl<$($bounded_ty: $bounds),*> $crate::Write for $ty {
#[inline]
fn write(&mut self, buf: &[u8]) -> $crate::io::Result<usize> {
fn write(&mut self, buf: &[u8]) -> $crate::Result<usize> {
$write_fn(self, buf)
}
#[inline]
fn flush(&mut self) -> $crate::io::Result<()> {
fn flush(&mut self) -> $crate::Result<()> {
$flush_fn(self)
}
}