Use full path in all macro usage of Result
This commit is contained in:
parent
fa716fb638
commit
aa6e5cd342
|
@ -12,7 +12,7 @@ macro_rules! impl_consensus_encoding {
|
||||||
fn consensus_encode<R: $crate::io::Write + ?Sized>(
|
fn consensus_encode<R: $crate::io::Write + ?Sized>(
|
||||||
&self,
|
&self,
|
||||||
r: &mut R,
|
r: &mut R,
|
||||||
) -> Result<usize, $crate::io::Error> {
|
) -> core::result::Result<usize, $crate::io::Error> {
|
||||||
let mut len = 0;
|
let mut len = 0;
|
||||||
$(len += self.$field.consensus_encode(r)?;)+
|
$(len += self.$field.consensus_encode(r)?;)+
|
||||||
Ok(len)
|
Ok(len)
|
||||||
|
@ -24,7 +24,7 @@ macro_rules! impl_consensus_encoding {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn consensus_decode_from_finite_reader<R: $crate::io::BufRead + ?Sized>(
|
fn consensus_decode_from_finite_reader<R: $crate::io::BufRead + ?Sized>(
|
||||||
r: &mut R,
|
r: &mut R,
|
||||||
) -> Result<$thing, $crate::consensus::encode::Error> {
|
) -> core::result::Result<$thing, $crate::consensus::encode::Error> {
|
||||||
Ok($thing {
|
Ok($thing {
|
||||||
$($field: $crate::consensus::Decodable::consensus_decode_from_finite_reader(r)?),+
|
$($field: $crate::consensus::Decodable::consensus_decode_from_finite_reader(r)?),+
|
||||||
})
|
})
|
||||||
|
@ -33,7 +33,7 @@ macro_rules! impl_consensus_encoding {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn consensus_decode<R: $crate::io::BufRead + ?Sized>(
|
fn consensus_decode<R: $crate::io::BufRead + ?Sized>(
|
||||||
r: &mut R,
|
r: &mut R,
|
||||||
) -> Result<$thing, $crate::consensus::encode::Error> {
|
) -> core::result::Result<$thing, $crate::consensus::encode::Error> {
|
||||||
let mut r = r.take($crate::consensus::encode::MAX_VEC_SIZE as u64);
|
let mut r = r.take($crate::consensus::encode::MAX_VEC_SIZE as u64);
|
||||||
Ok($thing {
|
Ok($thing {
|
||||||
$($field: $crate::consensus::Decodable::consensus_decode(&mut r)?),+
|
$($field: $crate::consensus::Decodable::consensus_decode(&mut r)?),+
|
||||||
|
@ -99,9 +99,9 @@ macro_rules! impl_bytes_newtype {
|
||||||
impl $crate::hex::FromHex for $t {
|
impl $crate::hex::FromHex for $t {
|
||||||
type Err = $crate::hex::HexToArrayError;
|
type Err = $crate::hex::HexToArrayError;
|
||||||
|
|
||||||
fn from_byte_iter<I>(iter: I) -> Result<Self, $crate::hex::HexToArrayError>
|
fn from_byte_iter<I>(iter: I) -> core::result::Result<Self, $crate::hex::HexToArrayError>
|
||||||
where
|
where
|
||||||
I: core::iter::Iterator<Item = Result<u8, $crate::hex::HexToBytesError>>
|
I: core::iter::Iterator<Item = core::result::Result<u8, $crate::hex::HexToBytesError>>
|
||||||
+ core::iter::ExactSizeIterator
|
+ core::iter::ExactSizeIterator
|
||||||
+ core::iter::DoubleEndedIterator,
|
+ core::iter::DoubleEndedIterator,
|
||||||
{
|
{
|
||||||
|
@ -111,12 +111,12 @@ macro_rules! impl_bytes_newtype {
|
||||||
|
|
||||||
impl core::str::FromStr for $t {
|
impl core::str::FromStr for $t {
|
||||||
type Err = $crate::hex::HexToArrayError;
|
type Err = $crate::hex::HexToArrayError;
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> { $crate::hex::FromHex::from_hex(s) }
|
fn from_str(s: &str) -> core::result::Result<Self, Self::Err> { $crate::hex::FromHex::from_hex(s) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
impl $crate::serde::Serialize for $t {
|
impl $crate::serde::Serialize for $t {
|
||||||
fn serialize<S: $crate::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: $crate::serde::Serializer>(&self, s: S) -> core::result::Result<S::Ok, S::Error> {
|
||||||
if s.is_human_readable() {
|
if s.is_human_readable() {
|
||||||
s.collect_str(self)
|
s.collect_str(self)
|
||||||
} else {
|
} else {
|
||||||
|
@ -127,7 +127,7 @@ macro_rules! impl_bytes_newtype {
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
impl<'de> $crate::serde::Deserialize<'de> for $t {
|
impl<'de> $crate::serde::Deserialize<'de> for $t {
|
||||||
fn deserialize<D: $crate::serde::Deserializer<'de>>(d: D) -> Result<$t, D::Error> {
|
fn deserialize<D: $crate::serde::Deserializer<'de>>(d: D) -> core::result::Result<$t, D::Error> {
|
||||||
if d.is_human_readable() {
|
if d.is_human_readable() {
|
||||||
struct HexVisitor;
|
struct HexVisitor;
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ macro_rules! impl_bytes_newtype {
|
||||||
f.write_str("an ASCII hex string")
|
f.write_str("an ASCII hex string")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
|
fn visit_bytes<E>(self, v: &[u8]) -> core::result::Result<Self::Value, E>
|
||||||
where
|
where
|
||||||
E: $crate::serde::de::Error,
|
E: $crate::serde::de::Error,
|
||||||
{
|
{
|
||||||
|
@ -151,7 +151,7 @@ macro_rules! impl_bytes_newtype {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
|
fn visit_str<E>(self, v: &str) -> core::result::Result<Self::Value, E>
|
||||||
where
|
where
|
||||||
E: $crate::serde::de::Error,
|
E: $crate::serde::de::Error,
|
||||||
{
|
{
|
||||||
|
@ -170,7 +170,7 @@ macro_rules! impl_bytes_newtype {
|
||||||
f.write_str("a bytestring")
|
f.write_str("a bytestring")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
|
fn visit_bytes<E>(self, v: &[u8]) -> core::result::Result<Self::Value, E>
|
||||||
where
|
where
|
||||||
E: $crate::serde::de::Error,
|
E: $crate::serde::de::Error,
|
||||||
{
|
{
|
||||||
|
@ -196,13 +196,13 @@ pub(crate) use impl_bytes_newtype;
|
||||||
macro_rules! impl_hashencode {
|
macro_rules! impl_hashencode {
|
||||||
($hashtype:ident) => {
|
($hashtype:ident) => {
|
||||||
impl $crate::consensus::Encodable for $hashtype {
|
impl $crate::consensus::Encodable for $hashtype {
|
||||||
fn consensus_encode<W: $crate::io::Write + ?Sized>(&self, w: &mut W) -> Result<usize, $crate::io::Error> {
|
fn consensus_encode<W: $crate::io::Write + ?Sized>(&self, w: &mut W) -> core::result::Result<usize, $crate::io::Error> {
|
||||||
self.0.consensus_encode(w)
|
self.0.consensus_encode(w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl $crate::consensus::Decodable for $hashtype {
|
impl $crate::consensus::Decodable for $hashtype {
|
||||||
fn consensus_decode<R: $crate::io::BufRead + ?Sized>(r: &mut R) -> Result<Self, $crate::consensus::encode::Error> {
|
fn consensus_decode<R: $crate::io::BufRead + ?Sized>(r: &mut R) -> core::result::Result<Self, $crate::consensus::encode::Error> {
|
||||||
use $crate::hashes::Hash;
|
use $crate::hashes::Hash;
|
||||||
Ok(Self::from_byte_array(<<$hashtype as $crate::hashes::Hash>::Bytes>::consensus_decode(r)?))
|
Ok(Self::from_byte_array(<<$hashtype as $crate::hashes::Hash>::Bytes>::consensus_decode(r)?))
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ macro_rules! impl_psbt_de_serialize {
|
||||||
macro_rules! impl_psbt_deserialize {
|
macro_rules! impl_psbt_deserialize {
|
||||||
($thing:ty) => {
|
($thing:ty) => {
|
||||||
impl $crate::psbt::serialize::Deserialize for $thing {
|
impl $crate::psbt::serialize::Deserialize for $thing {
|
||||||
fn deserialize(bytes: &[u8]) -> Result<Self, $crate::psbt::Error> {
|
fn deserialize(bytes: &[u8]) -> core::result::Result<Self, $crate::psbt::Error> {
|
||||||
$crate::consensus::deserialize(&bytes[..]).map_err(|e| $crate::psbt::Error::from(e))
|
$crate::consensus::deserialize(&bytes[..]).map_err(|e| $crate::psbt::Error::from(e))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ macro_rules! impl_psbtmap_serialize {
|
||||||
macro_rules! impl_psbtmap_deserialize {
|
macro_rules! impl_psbtmap_deserialize {
|
||||||
($thing:ty) => {
|
($thing:ty) => {
|
||||||
impl $crate::psbt::serialize::Deserialize for $thing {
|
impl $crate::psbt::serialize::Deserialize for $thing {
|
||||||
fn deserialize(bytes: &[u8]) -> Result<Self, $crate::psbt::Error> {
|
fn deserialize(bytes: &[u8]) -> core::result::Result<Self, $crate::psbt::Error> {
|
||||||
let mut decoder = bytes;
|
let mut decoder = bytes;
|
||||||
Self::decode(&mut decoder)
|
Self::decode(&mut decoder)
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ macro_rules! impl_psbtmap_decoding {
|
||||||
impl $thing {
|
impl $thing {
|
||||||
pub(crate) fn decode<R: $crate::io::BufRead + ?Sized>(
|
pub(crate) fn decode<R: $crate::io::BufRead + ?Sized>(
|
||||||
r: &mut R,
|
r: &mut R,
|
||||||
) -> Result<Self, $crate::psbt::Error> {
|
) -> core::result::Result<Self, $crate::psbt::Error> {
|
||||||
let mut rv: Self = core::default::Default::default();
|
let mut rv: Self = core::default::Default::default();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -148,7 +148,7 @@ macro_rules! impl_psbt_hash_de_serialize {
|
||||||
macro_rules! impl_psbt_hash_deserialize {
|
macro_rules! impl_psbt_hash_deserialize {
|
||||||
($hash_type:ty) => {
|
($hash_type:ty) => {
|
||||||
impl $crate::psbt::serialize::Deserialize for $hash_type {
|
impl $crate::psbt::serialize::Deserialize for $hash_type {
|
||||||
fn deserialize(bytes: &[u8]) -> Result<Self, $crate::psbt::Error> {
|
fn deserialize(bytes: &[u8]) -> core::result::Result<Self, $crate::psbt::Error> {
|
||||||
<$hash_type>::from_slice(&bytes[..]).map_err(|e| $crate::psbt::Error::from(e))
|
<$hash_type>::from_slice(&bytes[..]).map_err(|e| $crate::psbt::Error::from(e))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ macro_rules! hash_trait_impls {
|
||||||
|
|
||||||
impl<$($gen: $gent),*> str::FromStr for Hash<$($gen),*> {
|
impl<$($gen: $gent),*> str::FromStr for Hash<$($gen),*> {
|
||||||
type Err = $crate::hex::HexToArrayError;
|
type Err = $crate::hex::HexToArrayError;
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> $crate::_export::_core::result::Result<Self, Self::Err> {
|
||||||
use $crate::hex::{FromHex, HexToBytesIter};
|
use $crate::hex::{FromHex, HexToBytesIter};
|
||||||
use $crate::Hash;
|
use $crate::Hash;
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ macro_rules! hash_trait_impls {
|
||||||
from_engine(e)
|
from_engine(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_slice(sl: &[u8]) -> Result<Hash<$($gen),*>, FromSliceError> {
|
fn from_slice(sl: &[u8]) -> $crate::_export::_core::result::Result<Hash<$($gen),*>, FromSliceError> {
|
||||||
if sl.len() != $bits / 8 {
|
if sl.len() != $bits / 8 {
|
||||||
Err(FromSliceError{expected: Self::LEN, got: sl.len()})
|
Err(FromSliceError{expected: Self::LEN, got: sl.len()})
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -25,7 +25,7 @@ pub mod serde_details {
|
||||||
formatter.write_str("an ASCII hex string")
|
formatter.write_str("an ASCII hex string")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
|
fn visit_bytes<E>(self, v: &[u8]) -> core::result::Result<Self::Value, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,7 @@ pub mod serde_details {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
|
fn visit_str<E>(self, v: &str) -> core::result::Result<Self::Value, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,7 @@ pub mod serde_details {
|
||||||
formatter.write_str("a bytestring")
|
formatter.write_str("a bytestring")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
|
fn visit_bytes<E>(self, v: &[u8]) -> core::result::Result<Self::Value, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
{
|
{
|
||||||
|
@ -82,10 +82,10 @@ pub mod serde_details {
|
||||||
const N: usize;
|
const N: usize;
|
||||||
|
|
||||||
/// Helper function to turn a deserialized slice into the correct hash type.
|
/// Helper function to turn a deserialized slice into the correct hash type.
|
||||||
fn from_slice_delegated(sl: &[u8]) -> Result<Self, FromSliceError>;
|
fn from_slice_delegated(sl: &[u8]) -> core::result::Result<Self, FromSliceError>;
|
||||||
|
|
||||||
/// Do serde serialization.
|
/// Do serde serialization.
|
||||||
fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: Serializer>(&self, s: S) -> core::result::Result<S::Ok, S::Error> {
|
||||||
if s.is_human_readable() {
|
if s.is_human_readable() {
|
||||||
s.collect_str(self)
|
s.collect_str(self)
|
||||||
} else {
|
} else {
|
||||||
|
@ -94,7 +94,7 @@ pub mod serde_details {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Do serde deserialization.
|
/// Do serde deserialization.
|
||||||
fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
|
fn deserialize<'de, D: Deserializer<'de>>(d: D) -> core::result::Result<Self, D::Error> {
|
||||||
if d.is_human_readable() {
|
if d.is_human_readable() {
|
||||||
d.deserialize_str(HexVisitor::<Self>(PhantomData))
|
d.deserialize_str(HexVisitor::<Self>(PhantomData))
|
||||||
} else {
|
} else {
|
||||||
|
@ -112,7 +112,7 @@ macro_rules! serde_impl(
|
||||||
($t:ident, $len:expr $(, $gen:ident: $gent:ident)*) => (
|
($t:ident, $len:expr $(, $gen:ident: $gent:ident)*) => (
|
||||||
impl<$($gen: $gent),*> $crate::serde_macros::serde_details::SerdeHash for $t<$($gen),*> {
|
impl<$($gen: $gent),*> $crate::serde_macros::serde_details::SerdeHash for $t<$($gen),*> {
|
||||||
const N : usize = $len;
|
const N : usize = $len;
|
||||||
fn from_slice_delegated(sl: &[u8]) -> Result<Self, $crate::FromSliceError> {
|
fn from_slice_delegated(sl: &[u8]) -> core::result::Result<Self, $crate::FromSliceError> {
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use $crate::Hash as _;
|
use $crate::Hash as _;
|
||||||
$t::from_slice(sl)
|
$t::from_slice(sl)
|
||||||
|
@ -120,13 +120,13 @@ macro_rules! serde_impl(
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<$($gen: $gent),*> $crate::serde::Serialize for $t<$($gen),*> {
|
impl<$($gen: $gent),*> $crate::serde::Serialize for $t<$($gen),*> {
|
||||||
fn serialize<S: $crate::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: $crate::serde::Serializer>(&self, s: S) -> core::result::Result<S::Ok, S::Error> {
|
||||||
$crate::serde_macros::serde_details::SerdeHash::serialize(self, s)
|
$crate::serde_macros::serde_details::SerdeHash::serialize(self, s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de $(, $gen: $gent)*> $crate::serde::Deserialize<'de> for $t<$($gen),*> {
|
impl<'de $(, $gen: $gent)*> $crate::serde::Deserialize<'de> for $t<$($gen),*> {
|
||||||
fn deserialize<D: $crate::serde::Deserializer<'de>>(d: D) -> Result<$t<$($gen),*>, D::Error> {
|
fn deserialize<D: $crate::serde::Deserializer<'de>>(d: D) -> core::result::Result<$t<$($gen),*>, D::Error> {
|
||||||
$crate::serde_macros::serde_details::SerdeHash::deserialize(d)
|
$crate::serde_macros::serde_details::SerdeHash::deserialize(d)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ macro_rules! impl_array_newtype {
|
||||||
impl<'a> core::convert::TryFrom<&'a [$ty]> for $thing {
|
impl<'a> core::convert::TryFrom<&'a [$ty]> for $thing {
|
||||||
type Error = core::array::TryFromSliceError;
|
type Error = core::array::TryFromSliceError;
|
||||||
|
|
||||||
fn try_from(data: &'a [$ty]) -> Result<Self, Self::Error> {
|
fn try_from(data: &'a [$ty]) -> core::result::Result<Self, Self::Error> {
|
||||||
use core::convert::TryInto;
|
use core::convert::TryInto;
|
||||||
|
|
||||||
Ok($thing(data.try_into()?))
|
Ok($thing(data.try_into()?))
|
||||||
|
@ -99,7 +99,7 @@ macro_rules! impl_array_newtype {
|
||||||
macro_rules! debug_from_display {
|
macro_rules! debug_from_display {
|
||||||
($thing:ident) => {
|
($thing:ident) => {
|
||||||
impl core::fmt::Debug for $thing {
|
impl core::fmt::Debug for $thing {
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
|
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::result::Result<(), core::fmt::Error> {
|
||||||
core::fmt::Display::fmt(self, f)
|
core::fmt::Display::fmt(self, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue