From 6cf90132bce0d54a0d78e0b27939b20599264770 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 6 Jan 2025 16:11:16 +1100 Subject: [PATCH 1/2] io: Add traits So that our `io` crate is not surprising it seems we should generally, unless there is a good reason not to, follow `std::io`. Copy the derived trait implementations from `std::io` for `Cursor`, `Sink`, and `Take`. Done while investigating C-COMMON-TRAITS --- io/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/io/src/lib.rs b/io/src/lib.rs index c8d846dd5..5f747b289 100644 --- a/io/src/lib.rs +++ b/io/src/lib.rs @@ -192,7 +192,7 @@ impl BufRead for &[u8] { } /// Wraps an in memory reader providing the `position` function. -#[derive(Debug)] +#[derive(Clone, Debug, Default, Eq, PartialEq)] pub struct Cursor { inner: T, pos: u64, @@ -331,7 +331,7 @@ impl Write for &mut [u8] { /// A sink to which all writes succeed. See [`std::io::Sink`] for more info. /// /// Created using `io::sink()`. -#[derive(Debug)] +#[derive(Clone, Copy, Debug, Default)] pub struct Sink; impl Write for Sink { From 426f585a479ca20b7c3390c589b836f8726b9b03 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 9 Jan 2025 15:42:25 +1100 Subject: [PATCH 2/2] api: Run just check-api --- api/io/all-features.txt | 13 +++++++++++++ api/io/alloc-only.txt | 13 +++++++++++++ api/io/no-features.txt | 13 +++++++++++++ 3 files changed, 39 insertions(+) diff --git a/api/io/all-features.txt b/api/io/all-features.txt index fe3da3040..17d4ca33d 100644 --- a/api/io/all-features.txt +++ b/api/io/all-features.txt @@ -47,12 +47,14 @@ impl bitcoin_io::Write for std::net::tcp::TcpStream impl bitcoin_io::Write for std::os::unix::net::stream::UnixStream impl bitcoin_io::Write for std::process::ChildStdin impl core::clone::Clone for bitcoin_io::ErrorKind +impl core::clone::Clone for bitcoin_io::Sink impl core::cmp::Eq for bitcoin_io::ErrorKind impl core::cmp::PartialEq for bitcoin_io::ErrorKind impl core::convert::From for std::io::error::Error impl core::convert::From for bitcoin_io::Error impl core::convert::From for bitcoin_io::ErrorKind impl core::convert::From for bitcoin_io::Error +impl core::default::Default for bitcoin_io::Sink impl core::error::Error for bitcoin_io::Error impl core::fmt::Debug for bitcoin_io::Error impl core::fmt::Debug for bitcoin_io::ErrorKind @@ -60,6 +62,7 @@ impl core::fmt::Debug for bitcoin_io::Sink impl core::fmt::Display for bitcoin_io::Error impl core::hash::Hash for bitcoin_io::ErrorKind impl core::marker::Copy for bitcoin_io::ErrorKind +impl core::marker::Copy for bitcoin_io::Sink impl core::marker::Freeze for bitcoin_io::Error impl core::marker::Freeze for bitcoin_io::ErrorKind impl core::marker::Freeze for bitcoin_io::Sink @@ -102,11 +105,15 @@ impl std::io::Read for bitcoin_io::ToStd impl bitcoin_io::Write for &mut T impl bitcoin_io::Write for bitcoin_io::ToStd impl std::io::Write for bitcoin_io::ToStd +impl core::clone::Clone for bitcoin_io::Cursor +impl core::cmp::Eq for bitcoin_io::Cursor +impl core::cmp::PartialEq for bitcoin_io::Cursor impl> bitcoin_io::BufRead for bitcoin_io::Cursor impl> bitcoin_io::BufRead for std::io::cursor::Cursor impl> bitcoin_io::Cursor impl> bitcoin_io::Read for bitcoin_io::Cursor impl> bitcoin_io::Read for std::io::cursor::Cursor +impl core::default::Default for bitcoin_io::Cursor impl core::fmt::Debug for bitcoin_io::Cursor impl core::fmt::Debug for bitcoin_io::FromStd impl core::fmt::Debug for bitcoin_io::ToStd @@ -124,6 +131,7 @@ impl core::marker::Freeze for bitcoin_io::ToStd where T: core::marker::Fre impl core::marker::Send for bitcoin_io::Cursor where T: core::marker::Send impl core::marker::Send for bitcoin_io::FromStd where T: core::marker::Send impl core::marker::Send for bitcoin_io::ToStd where T: core::marker::Send +impl core::marker::StructuralPartialEq for bitcoin_io::Cursor impl core::marker::Sync for bitcoin_io::Cursor where T: core::marker::Sync impl core::marker::Sync for bitcoin_io::FromStd where T: core::marker::Sync impl core::marker::Sync for bitcoin_io::ToStd where T: core::marker::Sync @@ -217,7 +225,10 @@ pub fn alloc::vec::Vec::flush(&mut self) -> bitcoin_io::Result<()> pub fn alloc::vec::Vec::write(&mut self, buf: &[u8]) -> bitcoin_io::Result pub fn bitcoin_io::BufRead::consume(&mut self, amount: usize) pub fn bitcoin_io::BufRead::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]> +pub fn bitcoin_io::Cursor::clone(&self) -> bitcoin_io::Cursor pub fn bitcoin_io::Cursor::consume(&mut self, amount: usize) +pub fn bitcoin_io::Cursor::default() -> bitcoin_io::Cursor +pub fn bitcoin_io::Cursor::eq(&self, other: &bitcoin_io::Cursor) -> bool pub fn bitcoin_io::Cursor::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]> pub fn bitcoin_io::Cursor::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bitcoin_io::Cursor::get_mut(&mut self) -> &mut T @@ -268,6 +279,8 @@ pub fn bitcoin_io::Read::read(&mut self, buf: &mut [u8]) -> bitcoin_io::Result bitcoin_io::Result<()> pub fn bitcoin_io::Read::read_to_limit(&mut self, buf: &mut alloc::vec::Vec, limit: u64) -> bitcoin_io::Result pub fn bitcoin_io::Read::take(&mut self, limit: u64) -> bitcoin_io::Take<'_, Self> +pub fn bitcoin_io::Sink::clone(&self) -> bitcoin_io::Sink +pub fn bitcoin_io::Sink::default() -> bitcoin_io::Sink pub fn bitcoin_io::Sink::flush(&mut self) -> bitcoin_io::Result<()> pub fn bitcoin_io::Sink::flush(&mut self) -> std::io::error::Result<()> pub fn bitcoin_io::Sink::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result diff --git a/api/io/alloc-only.txt b/api/io/alloc-only.txt index 751069688..acd87863d 100644 --- a/api/io/alloc-only.txt +++ b/api/io/alloc-only.txt @@ -8,16 +8,19 @@ impl bitcoin_io::Write for &mut [u8] impl bitcoin_io::Write for alloc::vec::Vec impl bitcoin_io::Write for bitcoin_io::Sink impl core::clone::Clone for bitcoin_io::ErrorKind +impl core::clone::Clone for bitcoin_io::Sink impl core::cmp::Eq for bitcoin_io::ErrorKind impl core::cmp::PartialEq for bitcoin_io::ErrorKind impl core::convert::From for bitcoin_io::Error impl core::convert::From for bitcoin_io::ErrorKind +impl core::default::Default for bitcoin_io::Sink impl core::fmt::Debug for bitcoin_io::Error impl core::fmt::Debug for bitcoin_io::ErrorKind impl core::fmt::Debug for bitcoin_io::Sink impl core::fmt::Display for bitcoin_io::Error impl core::hash::Hash for bitcoin_io::ErrorKind impl core::marker::Copy for bitcoin_io::ErrorKind +impl core::marker::Copy for bitcoin_io::Sink impl core::marker::Freeze for bitcoin_io::Error impl core::marker::Freeze for bitcoin_io::ErrorKind impl core::marker::Freeze for bitcoin_io::Sink @@ -47,12 +50,17 @@ impl bitcoin_io::Take<'_, R> impl bitcoin_io::BufRead for &mut T impl bitcoin_io::Read for &mut T impl bitcoin_io::Write for &mut T +impl core::clone::Clone for bitcoin_io::Cursor +impl core::cmp::Eq for bitcoin_io::Cursor +impl core::cmp::PartialEq for bitcoin_io::Cursor impl> bitcoin_io::BufRead for bitcoin_io::Cursor impl> bitcoin_io::Cursor impl> bitcoin_io::Read for bitcoin_io::Cursor +impl core::default::Default for bitcoin_io::Cursor impl core::fmt::Debug for bitcoin_io::Cursor impl core::marker::Freeze for bitcoin_io::Cursor where T: core::marker::Freeze impl core::marker::Send for bitcoin_io::Cursor where T: core::marker::Send +impl core::marker::StructuralPartialEq for bitcoin_io::Cursor impl core::marker::Sync for bitcoin_io::Cursor where T: core::marker::Sync impl core::marker::Unpin for bitcoin_io::Cursor where T: core::marker::Unpin impl core::panic::unwind_safe::RefUnwindSafe for bitcoin_io::Cursor where T: core::panic::unwind_safe::RefUnwindSafe @@ -92,7 +100,10 @@ pub fn alloc::vec::Vec::flush(&mut self) -> bitcoin_io::Result<()> pub fn alloc::vec::Vec::write(&mut self, buf: &[u8]) -> bitcoin_io::Result pub fn bitcoin_io::BufRead::consume(&mut self, amount: usize) pub fn bitcoin_io::BufRead::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]> +pub fn bitcoin_io::Cursor::clone(&self) -> bitcoin_io::Cursor pub fn bitcoin_io::Cursor::consume(&mut self, amount: usize) +pub fn bitcoin_io::Cursor::default() -> bitcoin_io::Cursor +pub fn bitcoin_io::Cursor::eq(&self, other: &bitcoin_io::Cursor) -> bool pub fn bitcoin_io::Cursor::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]> pub fn bitcoin_io::Cursor::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bitcoin_io::Cursor::get_mut(&mut self) -> &mut T @@ -118,6 +129,8 @@ pub fn bitcoin_io::Read::read(&mut self, buf: &mut [u8]) -> bitcoin_io::Result bitcoin_io::Result<()> pub fn bitcoin_io::Read::read_to_limit(&mut self, buf: &mut alloc::vec::Vec, limit: u64) -> bitcoin_io::Result pub fn bitcoin_io::Read::take(&mut self, limit: u64) -> bitcoin_io::Take<'_, Self> +pub fn bitcoin_io::Sink::clone(&self) -> bitcoin_io::Sink +pub fn bitcoin_io::Sink::default() -> bitcoin_io::Sink pub fn bitcoin_io::Sink::flush(&mut self) -> bitcoin_io::Result<()> pub fn bitcoin_io::Sink::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bitcoin_io::Sink::write(&mut self, buf: &[u8]) -> bitcoin_io::Result diff --git a/api/io/no-features.txt b/api/io/no-features.txt index 0874dbcd9..15660438b 100644 --- a/api/io/no-features.txt +++ b/api/io/no-features.txt @@ -7,16 +7,19 @@ impl bitcoin_io::Read for &[u8] impl bitcoin_io::Write for &mut [u8] impl bitcoin_io::Write for bitcoin_io::Sink impl core::clone::Clone for bitcoin_io::ErrorKind +impl core::clone::Clone for bitcoin_io::Sink impl core::cmp::Eq for bitcoin_io::ErrorKind impl core::cmp::PartialEq for bitcoin_io::ErrorKind impl core::convert::From for bitcoin_io::Error impl core::convert::From for bitcoin_io::ErrorKind +impl core::default::Default for bitcoin_io::Sink impl core::fmt::Debug for bitcoin_io::Error impl core::fmt::Debug for bitcoin_io::ErrorKind impl core::fmt::Debug for bitcoin_io::Sink impl core::fmt::Display for bitcoin_io::Error impl core::hash::Hash for bitcoin_io::ErrorKind impl core::marker::Copy for bitcoin_io::ErrorKind +impl core::marker::Copy for bitcoin_io::Sink impl core::marker::Freeze for bitcoin_io::Error impl core::marker::Freeze for bitcoin_io::ErrorKind impl core::marker::Freeze for bitcoin_io::Sink @@ -45,12 +48,17 @@ impl bitcoin_io::Read for bitcoin_io impl bitcoin_io::BufRead for &mut T impl bitcoin_io::Read for &mut T impl bitcoin_io::Write for &mut T +impl core::clone::Clone for bitcoin_io::Cursor +impl core::cmp::Eq for bitcoin_io::Cursor +impl core::cmp::PartialEq for bitcoin_io::Cursor impl> bitcoin_io::BufRead for bitcoin_io::Cursor impl> bitcoin_io::Cursor impl> bitcoin_io::Read for bitcoin_io::Cursor +impl core::default::Default for bitcoin_io::Cursor impl core::fmt::Debug for bitcoin_io::Cursor impl core::marker::Freeze for bitcoin_io::Cursor where T: core::marker::Freeze impl core::marker::Send for bitcoin_io::Cursor where T: core::marker::Send +impl core::marker::StructuralPartialEq for bitcoin_io::Cursor impl core::marker::Sync for bitcoin_io::Cursor where T: core::marker::Sync impl core::marker::Unpin for bitcoin_io::Cursor where T: core::marker::Unpin impl core::panic::unwind_safe::RefUnwindSafe for bitcoin_io::Cursor where T: core::panic::unwind_safe::RefUnwindSafe @@ -88,7 +96,10 @@ pub fn &mut [u8]::flush(&mut self) -> bitcoin_io::Result<()> pub fn &mut [u8]::write(&mut self, buf: &[u8]) -> bitcoin_io::Result pub fn bitcoin_io::BufRead::consume(&mut self, amount: usize) pub fn bitcoin_io::BufRead::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]> +pub fn bitcoin_io::Cursor::clone(&self) -> bitcoin_io::Cursor pub fn bitcoin_io::Cursor::consume(&mut self, amount: usize) +pub fn bitcoin_io::Cursor::default() -> bitcoin_io::Cursor +pub fn bitcoin_io::Cursor::eq(&self, other: &bitcoin_io::Cursor) -> bool pub fn bitcoin_io::Cursor::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]> pub fn bitcoin_io::Cursor::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bitcoin_io::Cursor::get_mut(&mut self) -> &mut T @@ -111,6 +122,8 @@ pub fn bitcoin_io::ErrorKind::hash<__H: core::hash::Hasher>(&self, state: &mut _ pub fn bitcoin_io::Read::read(&mut self, buf: &mut [u8]) -> bitcoin_io::Result pub fn bitcoin_io::Read::read_exact(&mut self, buf: &mut [u8]) -> bitcoin_io::Result<()> pub fn bitcoin_io::Read::take(&mut self, limit: u64) -> bitcoin_io::Take<'_, Self> +pub fn bitcoin_io::Sink::clone(&self) -> bitcoin_io::Sink +pub fn bitcoin_io::Sink::default() -> bitcoin_io::Sink pub fn bitcoin_io::Sink::flush(&mut self) -> bitcoin_io::Result<()> pub fn bitcoin_io::Sink::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bitcoin_io::Sink::write(&mut self, buf: &[u8]) -> bitcoin_io::Result