2023-12-10 automated rustfmt nightly
This commit is contained in:
parent
aeb220ddc2
commit
8e7afe5d4a
|
@ -13,7 +13,6 @@ use crate::prelude::*;
|
||||||
use crate::sighash::{InvalidSighashTypeError, TapSighashType};
|
use crate::sighash::{InvalidSighashTypeError, TapSighashType};
|
||||||
use crate::taproot::serialized_signature::{self, SerializedSignature};
|
use crate::taproot::serialized_signature::{self, SerializedSignature};
|
||||||
|
|
||||||
|
|
||||||
/// A BIP340-341 serialized taproot signature with the corresponding hash type.
|
/// A BIP340-341 serialized taproot signature with the corresponding hash type.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
|
|
@ -11,8 +11,7 @@ use core::{fmt, ops};
|
||||||
|
|
||||||
pub use into_iter::IntoIter;
|
pub use into_iter::IntoIter;
|
||||||
|
|
||||||
use super::Signature;
|
use super::{SigFromSliceError, Signature};
|
||||||
use super::SigFromSliceError;
|
|
||||||
|
|
||||||
pub(crate) const MAX_LEN: usize = 65; // 64 for sig, 1B sighash flag
|
pub(crate) const MAX_LEN: usize = 65; // 64 for sig, 1B sighash flag
|
||||||
|
|
||||||
|
@ -58,9 +57,7 @@ impl PartialOrd for SerializedSignature {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ord for SerializedSignature {
|
impl Ord for SerializedSignature {
|
||||||
fn cmp(&self, other: &SerializedSignature) -> core::cmp::Ordering {
|
fn cmp(&self, other: &SerializedSignature) -> core::cmp::Ordering { (**self).cmp(&**other) }
|
||||||
(**self).cmp(&**other)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialOrd<[u8]> for SerializedSignature {
|
impl PartialOrd<[u8]> for SerializedSignature {
|
||||||
|
@ -76,9 +73,7 @@ impl PartialOrd<SerializedSignature> for [u8] {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl core::hash::Hash for SerializedSignature {
|
impl core::hash::Hash for SerializedSignature {
|
||||||
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
fn hash<H: core::hash::Hasher>(&self, state: &mut H) { (**self).hash(state) }
|
||||||
(**self).hash(state)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRef<[u8]> for SerializedSignature {
|
impl AsRef<[u8]> for SerializedSignature {
|
||||||
|
@ -117,23 +112,17 @@ impl<'a> IntoIterator for &'a SerializedSignature {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Signature> for SerializedSignature {
|
impl From<Signature> for SerializedSignature {
|
||||||
fn from(value: Signature) -> Self {
|
fn from(value: Signature) -> Self { Self::from_signature(&value) }
|
||||||
Self::from_signature(&value)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a Signature> for SerializedSignature {
|
impl<'a> From<&'a Signature> for SerializedSignature {
|
||||||
fn from(value: &'a Signature) -> Self {
|
fn from(value: &'a Signature) -> Self { Self::from_signature(value) }
|
||||||
Self::from_signature(value)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<SerializedSignature> for Signature {
|
impl TryFrom<SerializedSignature> for Signature {
|
||||||
type Error = SigFromSliceError;
|
type Error = SigFromSliceError;
|
||||||
|
|
||||||
fn try_from(value: SerializedSignature) -> Result<Self, Self::Error> {
|
fn try_from(value: SerializedSignature) -> Result<Self, Self::Error> { value.to_signature() }
|
||||||
value.to_signature()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TryFrom<&'a SerializedSignature> for Signature {
|
impl<'a> TryFrom<&'a SerializedSignature> for Signature {
|
||||||
|
@ -169,7 +158,9 @@ impl SerializedSignature {
|
||||||
/// Convert the serialized signature into the Signature struct.
|
/// Convert the serialized signature into the Signature struct.
|
||||||
/// (This deserializes it)
|
/// (This deserializes it)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_signature(&self) -> Result<Signature, SigFromSliceError> { Signature::from_slice(self) }
|
pub fn to_signature(&self) -> Result<Signature, SigFromSliceError> {
|
||||||
|
Signature::from_slice(self)
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a SerializedSignature from a Signature.
|
/// Create a SerializedSignature from a Signature.
|
||||||
/// (this serializes it)
|
/// (this serializes it)
|
||||||
|
|
|
@ -34,9 +34,7 @@ impl Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||||
pub fn get_ref(&self) -> Option<&(dyn Debug + Send + Sync + 'static)> {
|
pub fn get_ref(&self) -> Option<&(dyn Debug + Send + Sync + 'static)> { self.error.as_deref() }
|
||||||
self.error.as_deref()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ErrorKind> for Error {
|
impl From<ErrorKind> for Error {
|
||||||
|
|
Loading…
Reference in New Issue