Skip to content

Commit 26f762f

Browse files
authored
Merge pull request #4 from cryptidtech/simplify-deserialize
fix clippy warnings
2 parents 416ce22 + e3b60d5 commit 26f762f

File tree

5 files changed

+17
-24
lines changed

5 files changed

+17
-24
lines changed

src/serde/de.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,28 @@ impl<'de> Deserialize<'de> for AttrId {
3030
where
3131
E: Error,
3232
{
33-
AttrId::try_from(c).map_err(|e| Error::custom(e.to_string()))
33+
AttrId::try_from(c).map_err(E::custom)
3434
}
3535

3636
fn visit_str<E>(self, s: &str) -> Result<Self::Value, E>
3737
where
3838
E: Error,
3939
{
40-
AttrId::try_from(s).map_err(|e| Error::custom(e.to_string()))
40+
AttrId::try_from(s).map_err(E::custom)
4141
}
4242

4343
fn visit_borrowed_str<E>(self, s: &'de str) -> Result<Self::Value, E>
4444
where
4545
E: Error,
4646
{
47-
AttrId::try_from(s).map_err(|e| Error::custom(e.to_string()))
47+
AttrId::try_from(s).map_err(E::custom)
4848
}
4949

5050
fn visit_string<E>(self, s: String) -> Result<Self::Value, E>
5151
where
5252
E: Error,
5353
{
54-
AttrId::try_from(s.as_str()).map_err(|e| Error::custom(e.to_string()))
54+
AttrId::try_from(s.as_str()).map_err(E::custom)
5555
}
5656
}
5757

@@ -144,7 +144,7 @@ impl<'de> Deserialize<'de> for Multisig {
144144
deserializer.deserialize_struct(ms::SIGIL.as_str(), FIELDS, MultisigVisitor)
145145
} else {
146146
let b: &'de [u8] = Deserialize::deserialize(deserializer)?;
147-
Ok(Self::try_from(b).map_err(|e| Error::custom(e.to_string()))?)
147+
Ok(Self::try_from(b).map_err(D::Error::custom)?)
148148
}
149149
}
150150
}

src/views.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ pub mod ed25519;
99
/// Koblitz 256k1 curve implmentation (a.k.a. the Bitcoin curve)
1010
pub mod secp256k1;
1111

12-
///
13-
/// Attributes views let you inquire about the Multisig and retrieve data
14-
/// associated with the particular view.
15-
///
16-
1712
/// trait for returning the attributes of the Multisig
1813
pub trait AttrView {
1914
/// get the codec that the signed message was encoded with

src/views/bls12381.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ impl<'a> TryFrom<&'a Multisig> for View<'a> {
329329
}
330330
}
331331

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

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

370-
impl<'a> ConvView for View<'a> {
370+
impl ConvView for View<'_> {
371371
/// convert to SSH signature format
372372
fn to_ssh_signature(&self) -> Result<ssh_key::Signature, Error> {
373373
// get the signature data
@@ -450,7 +450,7 @@ impl<'a> ConvView for View<'a> {
450450
}
451451
}
452452

453-
impl<'a> ThresholdAttrView for View<'a> {
453+
impl ThresholdAttrView for View<'_> {
454454
/// get the threshold value for this multisig
455455
fn threshold(&self) -> Result<usize, Error> {
456456
let threshold = self
@@ -495,7 +495,7 @@ impl<'a> ThresholdAttrView for View<'a> {
495495
}
496496

497497
/// trait for accumulating shares to rebuild a threshold signature
498-
impl<'a> ThresholdView for View<'a> {
498+
impl ThresholdView for View<'_> {
499499
/// get the signature shares
500500
fn shares(&self) -> Result<Vec<Multisig>, Error> {
501501
// get the codec for the new share multisigs
@@ -606,9 +606,7 @@ impl<'a> ThresholdView for View<'a> {
606606
// the value from the first share added
607607
match av.payload_encoding() {
608608
Ok(encoding) => Some(encoding),
609-
Err(_) => {
610-
encoding
611-
}
609+
Err(_) => encoding,
612610
}
613611
};
614612

src/views/ed25519.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl<'a> TryFrom<&'a Multisig> for View<'a> {
1717
}
1818
}
1919

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

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

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

src/views/secp256k1.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl<'a> TryFrom<&'a Multisig> for View<'a> {
2020
}
2121
}
2222

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

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

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

0 commit comments

Comments
 (0)