Skip to content

fix clippy warnings #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/serde/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@ impl<'de> Deserialize<'de> for AttrId {
where
E: Error,
{
AttrId::try_from(c).map_err(|e| Error::custom(e.to_string()))
AttrId::try_from(c).map_err(E::custom)
}

fn visit_str<E>(self, s: &str) -> Result<Self::Value, E>
where
E: Error,
{
AttrId::try_from(s).map_err(|e| Error::custom(e.to_string()))
AttrId::try_from(s).map_err(E::custom)
}

fn visit_borrowed_str<E>(self, s: &'de str) -> Result<Self::Value, E>
where
E: Error,
{
AttrId::try_from(s).map_err(|e| Error::custom(e.to_string()))
AttrId::try_from(s).map_err(E::custom)
}

fn visit_string<E>(self, s: String) -> Result<Self::Value, E>
where
E: Error,
{
AttrId::try_from(s.as_str()).map_err(|e| Error::custom(e.to_string()))
AttrId::try_from(s.as_str()).map_err(E::custom)
}
}

Expand Down Expand Up @@ -144,7 +144,7 @@ impl<'de> Deserialize<'de> for Multisig {
deserializer.deserialize_struct(ms::SIGIL.as_str(), FIELDS, MultisigVisitor)
} else {
let b: &'de [u8] = Deserialize::deserialize(deserializer)?;
Ok(Self::try_from(b).map_err(|e| Error::custom(e.to_string()))?)
Ok(Self::try_from(b).map_err(D::Error::custom)?)
}
}
}
5 changes: 0 additions & 5 deletions src/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ pub mod ed25519;
/// Koblitz 256k1 curve implmentation (a.k.a. the Bitcoin curve)
pub mod secp256k1;

///
/// Attributes views let you inquire about the Multisig and retrieve data
/// associated with the particular view.
///

/// trait for returning the attributes of the Multisig
pub trait AttrView {
/// get the codec that the signed message was encoded with
Expand Down
14 changes: 6 additions & 8 deletions src/views/bls12381.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ impl<'a> TryFrom<&'a Multisig> for View<'a> {
}
}

impl<'a> AttrView for View<'a> {
impl AttrView for View<'_> {
/// for Bls Multisigs, the payload encoding is stored using the
/// SchemeTypeId::PayloadEncoding attribute id.
fn payload_encoding(&self) -> Result<Codec, Error> {
Expand All @@ -354,7 +354,7 @@ impl<'a> AttrView for View<'a> {
}
}

impl<'a> DataView for View<'a> {
impl DataView for View<'_> {
/// For Bls Multisig values, the sig data is stored using the
/// SchemeTypeId::SigData attribute id.
fn sig_bytes(&self) -> Result<Vec<u8>, Error> {
Expand All @@ -367,7 +367,7 @@ impl<'a> DataView for View<'a> {
}
}

impl<'a> ConvView for View<'a> {
impl ConvView for View<'_> {
/// convert to SSH signature format
fn to_ssh_signature(&self) -> Result<ssh_key::Signature, Error> {
// get the signature data
Expand Down Expand Up @@ -450,7 +450,7 @@ impl<'a> ConvView for View<'a> {
}
}

impl<'a> ThresholdAttrView for View<'a> {
impl ThresholdAttrView for View<'_> {
/// get the threshold value for this multisig
fn threshold(&self) -> Result<usize, Error> {
let threshold = self
Expand Down Expand Up @@ -495,7 +495,7 @@ impl<'a> ThresholdAttrView for View<'a> {
}

/// trait for accumulating shares to rebuild a threshold signature
impl<'a> ThresholdView for View<'a> {
impl ThresholdView for View<'_> {
/// get the signature shares
fn shares(&self) -> Result<Vec<Multisig>, Error> {
// get the codec for the new share multisigs
Expand Down Expand Up @@ -606,9 +606,7 @@ impl<'a> ThresholdView for View<'a> {
// the value from the first share added
match av.payload_encoding() {
Ok(encoding) => Some(encoding),
Err(_) => {
encoding
}
Err(_) => encoding,
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/views/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl<'a> TryFrom<&'a Multisig> for View<'a> {
}
}

impl<'a> AttrView for View<'a> {
impl AttrView for View<'_> {
/// for EdDSA Multisigs, the payload encoding is stored using the
/// AttrId::PayloadEncoding attribute id.
fn payload_encoding(&self) -> Result<Codec, Error> {
Expand All @@ -35,7 +35,7 @@ impl<'a> AttrView for View<'a> {
}
}

impl<'a> DataView for View<'a> {
impl DataView for View<'_> {
/// For EdDSA Multisig values, the sig data is stored using the
/// AttrId::SigData attribute id.
fn sig_bytes(&self) -> Result<Vec<u8>, Error> {
Expand All @@ -48,7 +48,7 @@ impl<'a> DataView for View<'a> {
}
}

impl<'a> ConvView for View<'a> {
impl ConvView for View<'_> {
/// convert to SSH signature format
fn to_ssh_signature(&self) -> Result<ssh_key::Signature, Error> {
// get the signature data
Expand Down
6 changes: 3 additions & 3 deletions src/views/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl<'a> TryFrom<&'a Multisig> for View<'a> {
}
}

impl<'a> AttrView for View<'a> {
impl AttrView for View<'_> {
/// for Es256K Multisigs, the payload encoding is stored using the
/// AttrId::PayloadEncoding attribute id.
fn payload_encoding(&self) -> Result<Codec, Error> {
Expand All @@ -38,7 +38,7 @@ impl<'a> AttrView for View<'a> {
}
}

impl<'a> DataView for View<'a> {
impl DataView for View<'_> {
/// For Secp256K1Pub Multisig values, the sig data is stored using the
/// AttrId::SigData attribute id.
fn sig_bytes(&self) -> Result<Vec<u8>, Error> {
Expand All @@ -51,7 +51,7 @@ impl<'a> DataView for View<'a> {
}
}

impl<'a> ConvView for View<'a> {
impl ConvView for View<'_> {
/// convert to SSH signature format
fn to_ssh_signature(&self) -> Result<ssh_key::Signature, Error> {
// get the signature data
Expand Down