Enable formatter for "src"
Remove the ignore for the "src" directory, this enables the formatter for all source files in the `src/` directory.
This commit is contained in:
parent
743b197124
commit
ee9a3ec6a1
|
@ -1,6 +1,5 @@
|
||||||
# Eventually this shoud be: ignore = []
|
# Eventually this shoud be: ignore = []
|
||||||
ignore = [
|
ignore = [
|
||||||
"src",
|
|
||||||
"src/blockdata",
|
"src/blockdata",
|
||||||
"src/consensus",
|
"src/consensus",
|
||||||
"src/network",
|
"src/network",
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
//! hash).
|
//! hash).
|
||||||
//!
|
//!
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
macro_rules! impl_hashencode {
|
macro_rules! impl_hashencode {
|
||||||
($hashtype:ident) => {
|
($hashtype:ident) => {
|
||||||
impl $crate::consensus::Encodable for $hashtype {
|
impl $crate::consensus::Encodable for $hashtype {
|
||||||
|
@ -23,7 +24,7 @@ macro_rules! impl_hashencode {
|
||||||
Ok(Self::from_inner(<<$hashtype as $crate::hashes::Hash>::Inner>::consensus_decode(r)?))
|
Ok(Self::from_inner(<<$hashtype as $crate::hashes::Hash>::Inner>::consensus_decode(r)?))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// newtypes module is solely here so we can rustfmt::skip.
|
// newtypes module is solely here so we can rustfmt::skip.
|
||||||
|
|
|
@ -100,11 +100,9 @@ macro_rules! impl_array_newtype {
|
||||||
type Output = <[$ty] as core::ops::Index<I>>::Output;
|
type Output = <[$ty] as core::ops::Index<I>>::Output;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn index(&self, index: I) -> &Self::Output {
|
fn index(&self, index: I) -> &Self::Output { &self.0[index] }
|
||||||
&self.0[index]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! display_from_debug {
|
macro_rules! display_from_debug {
|
||||||
|
@ -114,7 +112,7 @@ macro_rules! display_from_debug {
|
||||||
core::fmt::Debug::fmt(self, f)
|
core::fmt::Debug::fmt(self, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -352,8 +350,7 @@ macro_rules! serde_struct_human_string_impl {
|
||||||
/// - core::str::FromStr
|
/// - core::str::FromStr
|
||||||
/// - hashes::hex::FromHex
|
/// - hashes::hex::FromHex
|
||||||
macro_rules! impl_bytes_newtype {
|
macro_rules! impl_bytes_newtype {
|
||||||
($t:ident, $len:literal) => (
|
($t:ident, $len:literal) => {
|
||||||
|
|
||||||
impl core::fmt::LowerHex for $t {
|
impl core::fmt::LowerHex for $t {
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||||
for &ch in self.0.iter() {
|
for &ch in self.0.iter() {
|
||||||
|
@ -477,7 +474,7 @@ macro_rules! impl_bytes_newtype {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! user_enum {
|
macro_rules! user_enum {
|
||||||
|
@ -588,9 +585,7 @@ macro_rules! write_err {
|
||||||
|
|
||||||
/// Asserts a boolean expression at compile time.
|
/// Asserts a boolean expression at compile time.
|
||||||
macro_rules! const_assert {
|
macro_rules! const_assert {
|
||||||
($x:expr) => {
|
($x:expr) => {{
|
||||||
{
|
|
||||||
const _: [(); 0 - !$x as usize] = [];
|
const _: [(); 0 - !$x as usize] = [];
|
||||||
}
|
}};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
113
src/lib.rs
113
src/lib.rs
|
@ -29,11 +29,9 @@
|
||||||
//!
|
//!
|
||||||
|
|
||||||
#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
|
#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
|
||||||
|
|
||||||
// Experimental features we need.
|
// Experimental features we need.
|
||||||
#![cfg_attr(bench, feature(test))]
|
#![cfg_attr(bench, feature(test))]
|
||||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
|
|
||||||
// Coding conventions
|
// Coding conventions
|
||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
#![deny(non_upper_case_globals)]
|
#![deny(non_upper_case_globals)]
|
||||||
|
@ -55,7 +53,8 @@ compile_error!(
|
||||||
know if you want 16-bit support. Note that we do NOT guarantee that we will implement it!"
|
know if you want 16-bit support. Note that we do NOT guarantee that we will implement it!"
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(bench)] extern crate test;
|
#[cfg(bench)]
|
||||||
|
extern crate test;
|
||||||
|
|
||||||
#[cfg(feature = "no-std")]
|
#[cfg(feature = "no-std")]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -64,9 +63,10 @@ extern crate alloc;
|
||||||
extern crate core2;
|
extern crate core2;
|
||||||
|
|
||||||
// Re-exported dependencies.
|
// Re-exported dependencies.
|
||||||
#[macro_use] pub extern crate bitcoin_hashes as hashes;
|
#[macro_use]
|
||||||
pub extern crate secp256k1;
|
pub extern crate bitcoin_hashes as hashes;
|
||||||
pub extern crate bech32;
|
pub extern crate bech32;
|
||||||
|
pub extern crate secp256k1;
|
||||||
|
|
||||||
#[cfg(feature = "no-std")]
|
#[cfg(feature = "no-std")]
|
||||||
extern crate hashbrown;
|
extern crate hashbrown;
|
||||||
|
@ -75,12 +75,19 @@ extern crate hashbrown;
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
|
||||||
pub extern crate base64;
|
pub extern crate base64;
|
||||||
|
|
||||||
#[cfg(feature="bitcoinconsensus")] extern crate bitcoinconsensus;
|
#[cfg(feature = "bitcoinconsensus")]
|
||||||
#[cfg(feature = "serde")] #[macro_use] extern crate actual_serde as serde;
|
extern crate bitcoinconsensus;
|
||||||
#[cfg(all(test, feature = "serde"))] extern crate serde_json;
|
#[cfg(feature = "serde")]
|
||||||
#[cfg(all(test, feature = "serde"))] extern crate serde_test;
|
#[macro_use]
|
||||||
#[cfg(all(test, feature = "serde"))] extern crate bincode;
|
extern crate actual_serde as serde;
|
||||||
#[cfg(all(test, feature = "unstable"))] extern crate test;
|
#[cfg(all(test, feature = "serde"))]
|
||||||
|
extern crate bincode;
|
||||||
|
#[cfg(all(test, feature = "serde"))]
|
||||||
|
extern crate serde_json;
|
||||||
|
#[cfg(all(test, feature = "serde"))]
|
||||||
|
extern crate serde_test;
|
||||||
|
#[cfg(all(test, feature = "unstable"))]
|
||||||
|
extern crate test;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -93,45 +100,37 @@ mod serde_utils;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod network;
|
pub mod network;
|
||||||
pub mod blockdata;
|
pub mod blockdata;
|
||||||
pub mod util;
|
|
||||||
pub mod consensus;
|
pub mod consensus;
|
||||||
pub mod hash_types;
|
pub mod hash_types;
|
||||||
pub mod policy;
|
pub mod policy;
|
||||||
|
pub mod util;
|
||||||
pub use crate::hash_types::*;
|
|
||||||
pub use crate::blockdata::block::Block;
|
|
||||||
pub use crate::blockdata::block::BlockHeader;
|
|
||||||
pub use crate::blockdata::script::Script;
|
|
||||||
pub use crate::blockdata::transaction::Transaction;
|
|
||||||
pub use crate::blockdata::transaction::TxIn;
|
|
||||||
pub use crate::blockdata::transaction::Sequence;
|
|
||||||
pub use crate::blockdata::transaction::TxOut;
|
|
||||||
pub use crate::blockdata::transaction::OutPoint;
|
|
||||||
pub use crate::blockdata::transaction::EcdsaSighashType;
|
|
||||||
pub use crate::blockdata::witness::Witness;
|
|
||||||
pub use crate::consensus::encode::VarInt;
|
|
||||||
pub use crate::network::constants::Network;
|
|
||||||
pub use crate::util::Error;
|
|
||||||
pub use crate::util::address::Address;
|
|
||||||
pub use crate::util::address::AddressType;
|
|
||||||
pub use crate::util::amount::Amount;
|
|
||||||
pub use crate::util::amount::Denomination;
|
|
||||||
pub use crate::util::amount::SignedAmount;
|
|
||||||
pub use crate::util::merkleblock::MerkleBlock;
|
|
||||||
pub use crate::util::sighash::SchnorrSighashType;
|
|
||||||
|
|
||||||
pub use crate::util::ecdsa::{self, EcdsaSig, EcdsaSigError};
|
|
||||||
pub use crate::util::schnorr::{self, SchnorrSig, SchnorrSigError};
|
|
||||||
pub use crate::util::key::{PrivateKey, PublicKey, XOnlyPublicKey, KeyPair};
|
|
||||||
pub use crate::util::psbt;
|
|
||||||
#[allow(deprecated)]
|
|
||||||
pub use crate::blockdata::transaction::SigHashType;
|
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
use core2::io;
|
use core2::io;
|
||||||
|
|
||||||
|
pub use crate::blockdata::block::{Block, BlockHeader};
|
||||||
|
pub use crate::blockdata::script::Script;
|
||||||
|
#[allow(deprecated)]
|
||||||
|
pub use crate::blockdata::transaction::SigHashType;
|
||||||
|
pub use crate::blockdata::transaction::{
|
||||||
|
EcdsaSighashType, OutPoint, Sequence, Transaction, TxIn, TxOut,
|
||||||
|
};
|
||||||
|
pub use crate::blockdata::witness::Witness;
|
||||||
|
pub use crate::consensus::encode::VarInt;
|
||||||
|
pub use crate::hash_types::*;
|
||||||
|
pub use crate::network::constants::Network;
|
||||||
|
pub use crate::util::address::{Address, AddressType};
|
||||||
|
pub use crate::util::amount::{Amount, Denomination, SignedAmount};
|
||||||
|
pub use crate::util::ecdsa::{self, EcdsaSig, EcdsaSigError};
|
||||||
|
pub use crate::util::key::{KeyPair, PrivateKey, PublicKey, XOnlyPublicKey};
|
||||||
|
pub use crate::util::merkleblock::MerkleBlock;
|
||||||
|
pub use crate::util::schnorr::{self, SchnorrSig, SchnorrSigError};
|
||||||
|
pub use crate::util::sighash::SchnorrSighashType;
|
||||||
|
pub use crate::util::{psbt, Error};
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
mod io_extras {
|
mod io_extras {
|
||||||
/// A writer which will move data into the void.
|
/// A writer which will move data into the void.
|
||||||
|
@ -140,20 +139,14 @@ mod io_extras {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates an instance of a writer which will successfully consume all data.
|
/// Creates an instance of a writer which will successfully consume all data.
|
||||||
pub const fn sink() -> Sink {
|
pub const fn sink() -> Sink { Sink { _priv: () } }
|
||||||
Sink { _priv: () }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl core2::io::Write for Sink {
|
impl core2::io::Write for Sink {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn write(&mut self, buf: &[u8]) -> core2::io::Result<usize> {
|
fn write(&mut self, buf: &[u8]) -> core2::io::Result<usize> { Ok(buf.len()) }
|
||||||
Ok(buf.len())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn flush(&mut self) -> core2::io::Result<()> {
|
fn flush(&mut self) -> core2::io::Result<()> { Ok(()) }
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,32 +177,26 @@ mod prelude {
|
||||||
pub use std::collections::HashSet;
|
pub use std::collections::HashSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(bench)] use bench::EmptyWrite;
|
#[cfg(bench)]
|
||||||
|
use bench::EmptyWrite;
|
||||||
|
|
||||||
#[cfg(bench)]
|
#[cfg(bench)]
|
||||||
mod bench {
|
mod bench {
|
||||||
use core::fmt::Arguments;
|
use core::fmt::Arguments;
|
||||||
|
|
||||||
use crate::io::{IoSlice, Result, Write};
|
use crate::io::{IoSlice, Result, Write};
|
||||||
|
|
||||||
#[derive(Default, Clone, Debug, PartialEq, Eq)]
|
#[derive(Default, Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct EmptyWrite;
|
pub struct EmptyWrite;
|
||||||
|
|
||||||
impl Write for EmptyWrite {
|
impl Write for EmptyWrite {
|
||||||
fn write(&mut self, buf: &[u8]) -> Result<usize> {
|
fn write(&mut self, buf: &[u8]) -> Result<usize> { Ok(buf.len()) }
|
||||||
Ok(buf.len())
|
|
||||||
}
|
|
||||||
fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result<usize> {
|
fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result<usize> {
|
||||||
Ok(bufs.iter().map(|s| s.len()).sum())
|
Ok(bufs.iter().map(|s| s.len()).sum())
|
||||||
}
|
}
|
||||||
fn flush(&mut self) -> Result<()> {
|
fn flush(&mut self) -> Result<()> { Ok(()) }
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn write_all(&mut self, _: &[u8]) -> Result<()> {
|
fn write_all(&mut self, _: &[u8]) -> Result<()> { Ok(()) }
|
||||||
Ok(())
|
fn write_fmt(&mut self, _: Arguments) -> Result<()> { Ok(()) }
|
||||||
}
|
|
||||||
fn write_fmt(&mut self, _: Arguments) -> Result<()> {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,10 @@
|
||||||
//! These values were taken from bitcoind v0.21.1 (194b9b8792d9b0798fdb570b79fa51f1d1f5ebaf).
|
//! These values were taken from bitcoind v0.21.1 (194b9b8792d9b0798fdb570b79fa51f1d1f5ebaf).
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use super::blockdata::constants::{MAX_BLOCK_SIGOPS_COST, WITNESS_SCALE_FACTOR};
|
|
||||||
use core::cmp;
|
use core::cmp;
|
||||||
|
|
||||||
|
use super::blockdata::constants::{MAX_BLOCK_SIGOPS_COST, WITNESS_SCALE_FACTOR};
|
||||||
|
|
||||||
/// Maximum weight of a transaction for it to be relayed by most nodes on the network
|
/// Maximum weight of a transaction for it to be relayed by most nodes on the network
|
||||||
pub const MAX_STANDARD_TX_WEIGHT: u32 = 400_000;
|
pub const MAX_STANDARD_TX_WEIGHT: u32 = 400_000;
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,11 @@ pub mod btreemap_byte_values {
|
||||||
|
|
||||||
// NOTE: This module can be exactly copied to use with HashMap.
|
// NOTE: This module can be exactly copied to use with HashMap.
|
||||||
|
|
||||||
use crate::prelude::*;
|
|
||||||
use crate::hashes::hex::{FromHex, ToHex};
|
|
||||||
use serde;
|
use serde;
|
||||||
|
|
||||||
|
use crate::hashes::hex::{FromHex, ToHex};
|
||||||
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub fn serialize<S, T>(v: &BTreeMap<T, Vec<u8>>, s: S) -> Result<S::Ok, S::Error>
|
pub fn serialize<S, T>(v: &BTreeMap<T, Vec<u8>>, s: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: serde::Serializer,
|
S: serde::Serializer,
|
||||||
|
@ -52,9 +53,10 @@ pub mod btreemap_byte_values {
|
||||||
write!(f, "a map with hexadecimal values")
|
write!(f, "a map with hexadecimal values")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_map<A: serde::de::MapAccess<'de>>(self, mut a: A)
|
fn visit_map<A: serde::de::MapAccess<'de>>(
|
||||||
-> Result<Self::Value, A::Error>
|
self,
|
||||||
{
|
mut a: A,
|
||||||
|
) -> Result<Self::Value, A::Error> {
|
||||||
let mut ret = BTreeMap::new();
|
let mut ret = BTreeMap::new();
|
||||||
while let Some((key, value)) = a.next_entry()? {
|
while let Some((key, value)) = a.next_entry()? {
|
||||||
ret.insert(key, FromHex::from_hex(value).map_err(serde::de::Error::custom)?);
|
ret.insert(key, FromHex::from_hex(value).map_err(serde::de::Error::custom)?);
|
||||||
|
@ -79,9 +81,10 @@ pub mod btreemap_as_seq {
|
||||||
|
|
||||||
// NOTE: This module can be exactly copied to use with HashMap.
|
// NOTE: This module can be exactly copied to use with HashMap.
|
||||||
|
|
||||||
use crate::prelude::*;
|
|
||||||
use serde;
|
use serde;
|
||||||
|
|
||||||
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub fn serialize<S, T, U>(v: &BTreeMap<T, U>, s: S) -> Result<S::Ok, S::Error>
|
pub fn serialize<S, T, U>(v: &BTreeMap<T, U>, s: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: serde::Serializer,
|
S: serde::Serializer,
|
||||||
|
@ -122,9 +125,10 @@ pub mod btreemap_as_seq {
|
||||||
write!(f, "a sequence of pairs")
|
write!(f, "a sequence of pairs")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_seq<A: serde::de::SeqAccess<'de>>(self, mut a: A)
|
fn visit_seq<A: serde::de::SeqAccess<'de>>(
|
||||||
-> Result<Self::Value, A::Error>
|
self,
|
||||||
{
|
mut a: A,
|
||||||
|
) -> Result<Self::Value, A::Error> {
|
||||||
let mut ret = BTreeMap::new();
|
let mut ret = BTreeMap::new();
|
||||||
while let Some((key, value)) = a.next_element()? {
|
while let Some((key, value)) = a.next_element()? {
|
||||||
ret.insert(key, value);
|
ret.insert(key, value);
|
||||||
|
@ -149,16 +153,16 @@ pub mod btreemap_as_seq_byte_values {
|
||||||
|
|
||||||
// NOTE: This module can be exactly copied to use with HashMap.
|
// NOTE: This module can be exactly copied to use with HashMap.
|
||||||
|
|
||||||
use crate::prelude::*;
|
|
||||||
use serde;
|
use serde;
|
||||||
|
|
||||||
|
use crate::prelude::*;
|
||||||
|
|
||||||
/// A custom key-value pair type that serialized the bytes as hex.
|
/// A custom key-value pair type that serialized the bytes as hex.
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(crate = "actual_serde")]
|
#[serde(crate = "actual_serde")]
|
||||||
struct OwnedPair<T>(
|
struct OwnedPair<T>(
|
||||||
T,
|
T,
|
||||||
#[serde(deserialize_with = "crate::serde_utils::hex_bytes::deserialize")]
|
#[serde(deserialize_with = "crate::serde_utils::hex_bytes::deserialize")] Vec<u8>,
|
||||||
Vec<u8>,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/// A custom key-value pair type that serialized the bytes as hex.
|
/// A custom key-value pair type that serialized the bytes as hex.
|
||||||
|
@ -166,8 +170,7 @@ pub mod btreemap_as_seq_byte_values {
|
||||||
#[serde(crate = "actual_serde")]
|
#[serde(crate = "actual_serde")]
|
||||||
struct BorrowedPair<'a, T: 'static>(
|
struct BorrowedPair<'a, T: 'static>(
|
||||||
&'a T,
|
&'a T,
|
||||||
#[serde(serialize_with = "crate::serde_utils::hex_bytes::serialize")]
|
#[serde(serialize_with = "crate::serde_utils::hex_bytes::serialize")] &'a [u8],
|
||||||
&'a [u8],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
pub fn serialize<S, T>(v: &BTreeMap<T, Vec<u8>>, s: S) -> Result<S::Ok, S::Error>
|
pub fn serialize<S, T>(v: &BTreeMap<T, Vec<u8>>, s: S) -> Result<S::Ok, S::Error>
|
||||||
|
@ -207,9 +210,10 @@ pub mod btreemap_as_seq_byte_values {
|
||||||
write!(f, "a sequence of pairs")
|
write!(f, "a sequence of pairs")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_seq<A: serde::de::SeqAccess<'de>>(self, mut a: A)
|
fn visit_seq<A: serde::de::SeqAccess<'de>>(
|
||||||
-> Result<Self::Value, A::Error>
|
self,
|
||||||
{
|
mut a: A,
|
||||||
|
) -> Result<Self::Value, A::Error> {
|
||||||
let mut ret = BTreeMap::new();
|
let mut ret = BTreeMap::new();
|
||||||
while let Option::Some(OwnedPair(key, value)) = a.next_element()? {
|
while let Option::Some(OwnedPair(key, value)) = a.next_element()? {
|
||||||
ret.insert(key, value);
|
ret.insert(key, value);
|
||||||
|
@ -236,7 +240,8 @@ pub mod hex_bytes {
|
||||||
|
|
||||||
pub fn serialize<T, S>(bytes: &T, s: S) -> Result<S::Ok, S::Error>
|
pub fn serialize<T, S>(bytes: &T, s: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
T: serde::Serialize + AsRef<[u8]>, S: serde::Serializer
|
T: serde::Serialize + AsRef<[u8]>,
|
||||||
|
S: serde::Serializer,
|
||||||
{
|
{
|
||||||
// Don't do anything special when not human readable.
|
// Don't do anything special when not human readable.
|
||||||
if !s.is_human_readable() {
|
if !s.is_human_readable() {
|
||||||
|
@ -248,7 +253,8 @@ pub mod hex_bytes {
|
||||||
|
|
||||||
pub fn deserialize<'de, D, B>(d: D) -> Result<B, D::Error>
|
pub fn deserialize<'de, D, B>(d: D) -> Result<B, D::Error>
|
||||||
where
|
where
|
||||||
D: serde::Deserializer<'de>, B: serde::Deserialize<'de> + FromHex,
|
D: serde::Deserializer<'de>,
|
||||||
|
B: serde::Deserialize<'de> + FromHex,
|
||||||
{
|
{
|
||||||
struct Visitor<B>(core::marker::PhantomData<B>);
|
struct Visitor<B>(core::marker::PhantomData<B>);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue