From ac5fdd89952cacd48183abbfaf13d0686119a8f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Tue, 26 Mar 2024 14:40:07 +0100 Subject: [PATCH 1/4] refactor: Remove unnecessary constraint --- src/invocation/payload.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/invocation/payload.rs b/src/invocation/payload.rs index 6e92ae64..728a2dfe 100644 --- a/src/invocation/payload.rs +++ b/src/invocation/payload.rs @@ -366,9 +366,7 @@ where } } -impl<'de, A: ParseAbility + Deserialize<'de>, DID: Did + Deserialize<'de>> Deserialize<'de> - for Payload -{ +impl<'de, A: ParseAbility, DID: Did + Deserialize<'de>> Deserialize<'de> for Payload { fn deserialize(deserializer: D) -> Result, D::Error> where D: de::Deserializer<'de>, @@ -379,7 +377,7 @@ impl<'de, A: ParseAbility + Deserialize<'de>, DID: Did + Deserialize<'de>> Deser "iss", "sub", "aud", "cmd", "args", "prf", "nonce", "cause", "meta", "iat", "exp", ]; - impl<'de, T: ParseAbility + Deserialize<'de>, DID: Did + Deserialize<'de>> Visitor<'de> + impl<'de, T: ParseAbility, DID: Did + Deserialize<'de>> Visitor<'de> for InvocationPayloadVisitor { type Value = Payload; @@ -480,7 +478,7 @@ impl<'de, A: ParseAbility + Deserialize<'de>, DID: Did + Deserialize<'de>> Deser let ability = ::try_parse(cmd.as_str(), args).map_err(|e| { de::Error::custom(format!( - "Unable to parse ability field for {:?} becuase {:?}", + "Unable to parse ability field for {:?} because {:?}", cmd, e )) })?; From 765103ff1ef055f0579b77df98b162a1e8e39baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Tue, 26 Mar 2024 14:43:21 +0100 Subject: [PATCH 2/4] refactor: Remove uneccessary constriant --- src/crypto/varsig/header/eddsa.rs | 2 +- src/crypto/varsig/header/es256.rs | 2 +- src/crypto/varsig/header/es256k.rs | 2 +- src/crypto/varsig/header/es512.rs | 2 +- src/crypto/varsig/header/rs256.rs | 2 +- src/crypto/varsig/header/rs512.rs | 2 +- src/delegation.rs | 2 +- src/delegation/agent.rs | 2 +- src/invocation/agent.rs | 4 ++-- src/invocation/store/memory.rs | 12 ++++-------- src/invocation/store/traits.rs | 11 +++-------- src/receipt.rs | 2 +- src/receipt/store/memory.rs | 12 ++++-------- src/receipt/store/traits.rs | 2 +- 14 files changed, 23 insertions(+), 36 deletions(-) diff --git a/src/crypto/varsig/header/eddsa.rs b/src/crypto/varsig/header/eddsa.rs index 5dd2009e..d16d7137 100644 --- a/src/crypto/varsig/header/eddsa.rs +++ b/src/crypto/varsig/header/eddsa.rs @@ -33,7 +33,7 @@ impl + Clone> From> for Vec { } } -impl + TryFrom> Header for EdDsaHeader { +impl Header for EdDsaHeader { type Signature = ed25519_dalek::Signature; type Verifier = ed25519_dalek::VerifyingKey; diff --git a/src/crypto/varsig/header/es256.rs b/src/crypto/varsig/header/es256.rs index 4e53a460..ba57f06d 100644 --- a/src/crypto/varsig/header/es256.rs +++ b/src/crypto/varsig/header/es256.rs @@ -38,7 +38,7 @@ impl> From> for Vec { } } -impl + TryFrom> Header for Es256Header { +impl Header for Es256Header { type Signature = p256::ecdsa::Signature; type Verifier = p256::ecdsa::VerifyingKey; diff --git a/src/crypto/varsig/header/es256k.rs b/src/crypto/varsig/header/es256k.rs index 465c4338..17bd7c67 100644 --- a/src/crypto/varsig/header/es256k.rs +++ b/src/crypto/varsig/header/es256k.rs @@ -38,7 +38,7 @@ impl> From> for Vec { } } -impl + TryFrom> Header for Es256kHeader { +impl Header for Es256kHeader { type Signature = k256::ecdsa::Signature; type Verifier = k256::ecdsa::VerifyingKey; diff --git a/src/crypto/varsig/header/es512.rs b/src/crypto/varsig/header/es512.rs index 07089fac..c14b4723 100644 --- a/src/crypto/varsig/header/es512.rs +++ b/src/crypto/varsig/header/es512.rs @@ -38,7 +38,7 @@ impl> From> for Vec { } } -impl + TryFrom> Header for Es512Header { +impl Header for Es512Header { type Signature = p521::ecdsa::Signature; type Verifier = p521::ecdsa::VerifyingKey; diff --git a/src/crypto/varsig/header/rs256.rs b/src/crypto/varsig/header/rs256.rs index bc137ecb..4f559d80 100644 --- a/src/crypto/varsig/header/rs256.rs +++ b/src/crypto/varsig/header/rs256.rs @@ -51,7 +51,7 @@ impl> From> for Vec { } } -impl + TryFrom> Header for Rs256Header { +impl Header for Rs256Header { type Signature = Signature; type Verifier = VerifyingKey; diff --git a/src/crypto/varsig/header/rs512.rs b/src/crypto/varsig/header/rs512.rs index 7b9d161d..60c77adf 100644 --- a/src/crypto/varsig/header/rs512.rs +++ b/src/crypto/varsig/header/rs512.rs @@ -39,7 +39,7 @@ impl> From> for Vec { } } -impl + TryFrom> Header for Rs512Header { +impl Header for Rs512Header { type Signature = Signature; type Verifier = VerifyingKey; diff --git a/src/delegation.rs b/src/delegation.rs index e25aa5fe..822c168a 100644 --- a/src/delegation.rs +++ b/src/delegation.rs @@ -65,7 +65,7 @@ impl, C: Codec + TryFrom + Into> Capsul const TAG: &'static str = "ucan/prf"; } -impl, C: Codec + Into + TryFrom> Delegation { +impl, C: Codec> Delegation { pub fn new( varsig_header: V, signature: DID::Signature, diff --git a/src/delegation/agent.rs b/src/delegation/agent.rs index 7e9cc9c7..4fb8280c 100644 --- a/src/delegation/agent.rs +++ b/src/delegation/agent.rs @@ -23,7 +23,7 @@ pub struct Agent< S: Store, DID: Did + Clone = did::preset::Verifier, V: varsig::Header + Clone = varsig::header::Preset, - C: Codec + Into + TryFrom = varsig::encoding::Preset, + C: Codec = varsig::encoding::Preset, > where Ipld: Encode, Payload: TryFrom>, diff --git a/src/invocation/agent.rs b/src/invocation/agent.rs index e50aefc0..095c55ed 100644 --- a/src/invocation/agent.rs +++ b/src/invocation/agent.rs @@ -37,7 +37,7 @@ pub struct Agent< T: ToCommand = ability::preset::Preset, DID: Did + Clone = did::preset::Verifier, V: varsig::Header + Clone = varsig::header::Preset, - C: Codec + Into + TryFrom = varsig::encoding::Preset, + C: Codec = varsig::encoding::Preset, > where Ipld: Encode, delegation::Payload: TryFrom>, @@ -67,7 +67,7 @@ where S: Store, D: delegation::store::Store, V: varsig::Header + Clone, - C: Codec + Into + TryFrom, + C: Codec, >::InvocationStoreError: fmt::Debug, >::DelegationStoreError: fmt::Debug, delegation::Payload: TryFrom>, diff --git a/src/invocation/store/memory.rs b/src/invocation/store/memory.rs index 7c7c7196..4b0a9f3f 100644 --- a/src/invocation/store/memory.rs +++ b/src/invocation/store/memory.rs @@ -24,9 +24,7 @@ pub struct MemoryStoreInner< store: BTreeMap>>, } -impl, Enc: Codec + Into + TryFrom> - MemoryStore -{ +impl, Enc: Codec> MemoryStore { fn lock(&self) -> MutexGuard<'_, MemoryStoreInner> { match self.inner.lock() { Ok(guard) => guard, @@ -38,9 +36,7 @@ impl, Enc: Codec + Into + TryFrom> } } -impl, Enc: Codec + Into + TryFrom> Default - for MemoryStore -{ +impl, Enc: Codec> Default for MemoryStore { fn default() -> Self { Self { inner: Arc::new(Mutex::new(MemoryStoreInner { @@ -50,8 +46,8 @@ impl, Enc: Codec + Into + TryFrom> } } -impl, Enc: Codec + Into + TryFrom> - Store for MemoryStore +impl, Enc: Codec> Store + for MemoryStore { type InvocationStoreError = Infallible; diff --git a/src/invocation/store/traits.rs b/src/invocation/store/traits.rs index 6d3fc723..5af8d355 100644 --- a/src/invocation/store/traits.rs +++ b/src/invocation/store/traits.rs @@ -2,7 +2,7 @@ use crate::{crypto::varsig, did::Did, invocation::Invocation}; use libipld_core::{cid::Cid, codec::Codec}; use std::sync::Arc; -pub trait Store, C: Codec + Into + TryFrom> { +pub trait Store, C: Codec> { type InvocationStoreError; fn get( @@ -21,13 +21,8 @@ pub trait Store, C: Codec + Into + TryFro } } -impl< - S: Store, - T, - DID: Did, - V: varsig::Header, - C: Codec + Into + TryFrom, - > Store for &S +impl, T, DID: Did, V: varsig::Header, C: Codec> Store + for &S { type InvocationStoreError = >::InvocationStoreError; diff --git a/src/receipt.rs b/src/receipt.rs index 537d5335..a8837f98 100644 --- a/src/receipt.rs +++ b/src/receipt.rs @@ -28,7 +28,7 @@ pub struct Receipt< T: Responds, DID: Did = did::preset::Verifier, V: varsig::Header = varsig::header::Preset, - C: Codec + Into + TryFrom = varsig::encoding::Preset, + C: Codec = varsig::encoding::Preset, > { pub varsig_header: V, pub signature: DID::Signature, diff --git a/src/receipt/store/memory.rs b/src/receipt/store/memory.rs index 6be098fa..955ffada 100644 --- a/src/receipt/store/memory.rs +++ b/src/receipt/store/memory.rs @@ -10,19 +10,15 @@ use std::{collections::BTreeMap, convert::Infallible, fmt}; /// An in-memory [`receipt::Store`][crate::receipt::Store]. #[derive(Debug, Clone, PartialEq)] -pub struct MemoryStore< - T: Responds, - DID: Did, - V: varsig::Header, - Enc: Codec + Into + TryFrom, -> where +pub struct MemoryStore, Enc: Codec> +where T::Success: fmt::Debug + Clone + PartialEq, { store: BTreeMap>, } -impl, Enc: Codec + Into + TryFrom> - Store for MemoryStore +impl, Enc: Codec> Store + for MemoryStore where ::Success: TryFrom + Into + Clone + fmt::Debug + PartialEq, { diff --git a/src/receipt/store/traits.rs b/src/receipt/store/traits.rs index 8d53a1f0..2bb52329 100644 --- a/src/receipt/store/traits.rs +++ b/src/receipt/store/traits.rs @@ -7,7 +7,7 @@ use crate::{ use libipld_core::{codec::Codec, ipld::Ipld}; /// A store for [`Receipt`]s indexed by their [`task::Id`]s. -pub trait Store, C: Codec + Into + TryFrom> { +pub trait Store, C: Codec> { /// The error type representing all the ways a store operation can fail. type Error; From a9f318c886846c4be1f19e1ad2300e675442c935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Tue, 26 Mar 2024 14:44:40 +0100 Subject: [PATCH 3/4] refactor: Remove even more unnecessary constraints --- src/ability/pipe.rs | 8 +++---- src/ability/ucan/batch.rs | 4 ++-- src/crypto/signature/envelope.rs | 2 +- src/crypto/varsig/header/traits.rs | 4 +--- src/delegation.rs | 18 ++++++--------- src/delegation/agent.rs | 8 ++----- src/delegation/store/memory.rs | 23 ++++++------------- src/delegation/store/traits.rs | 10 +++----- src/invocation.rs | 22 ++++++++---------- src/invocation/agent.rs | 10 ++------ src/invocation/store/memory.rs | 4 ++-- src/receipt.rs | 37 ++++++++---------------------- 12 files changed, 50 insertions(+), 100 deletions(-) diff --git a/src/ability/pipe.rs b/src/ability/pipe.rs index 536fd55a..e31e3bc2 100644 --- a/src/ability/pipe.rs +++ b/src/ability/pipe.rs @@ -1,22 +1,22 @@ use crate::{crypto::varsig, delegation, did::Did, ipld}; use libipld_core::{codec::Codec, ipld::Ipld}; -pub struct Pipe, C: Codec + TryFrom + Into> { +pub struct Pipe, C: Codec> { pub source: Cap, pub sink: Cap, } -pub enum Cap, C: Codec + TryFrom + Into> { +pub enum Cap, C: Codec> { Proof(delegation::Proof), Literal(Ipld), } -pub struct PromisedPipe, C: Codec + TryFrom + Into> { +pub struct PromisedPipe, C: Codec> { pub source: PromisedCap, pub sink: PromisedCap, } -pub enum PromisedCap, C: Codec + TryFrom + Into> { +pub enum PromisedCap, C: Codec> { Proof(delegation::Proof), Promised(ipld::Promised), } diff --git a/src/ability/ucan/batch.rs b/src/ability/ucan/batch.rs index 9712fd93..983500df 100644 --- a/src/ability/ucan/batch.rs +++ b/src/ability/ucan/batch.rs @@ -3,11 +3,11 @@ // use std::collections::BTreeMap; // // #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -// pub struct Batch, Enc: Codec + TryFrom + Into> { +// pub struct Batch, Enc: Codec> { // pub batch: Vec>, // FIXME not quite right; would be nice to include meta etc // } // -// pub struct Step, Enc: Codec + TryFrom + Into> { +// pub struct Step, Enc: Codec> { // pub subject: DID, // pub audience: Option, // pub ability: A, // FIXME promise version instead? Promised version shoudl be able to promise any field diff --git a/src/crypto/signature/envelope.rs b/src/crypto/signature/envelope.rs index 170b719d..58282a53 100644 --- a/src/crypto/signature/envelope.rs +++ b/src/crypto/signature/envelope.rs @@ -16,7 +16,7 @@ pub trait Envelope: Sized { type DID: Did; type Payload: Clone + Capsule + TryFrom> + Into>; type VarsigHeader: varsig::Header + Clone; - type Encoder: Codec + TryFrom + Into; + type Encoder: Codec; fn varsig_header(&self) -> &Self::VarsigHeader; fn signature(&self) -> &::Signature; diff --git a/src/crypto/varsig/header/traits.rs b/src/crypto/varsig/header/traits.rs index a91bfe29..e6da044c 100644 --- a/src/crypto/varsig/header/traits.rs +++ b/src/crypto/varsig/header/traits.rs @@ -2,9 +2,7 @@ use libipld_core::codec::{Codec, Encode}; use signature::Verifier; use thiserror::Error; -pub trait Header + Into>: - for<'a> TryFrom<&'a [u8]> + Into> -{ +pub trait Header: for<'a> TryFrom<&'a [u8]> + Into> { type Signature: signature::SignatureEncoding; type Verifier: signature::Verifier; diff --git a/src/delegation.rs b/src/delegation.rs index 822c168a..e5c75842 100644 --- a/src/delegation.rs +++ b/src/delegation.rs @@ -42,7 +42,7 @@ use web_time::SystemTime; pub struct Delegation< DID: Did = did::preset::Verifier, V: varsig::Header = varsig::header::Preset, - C: Codec + TryFrom + Into = varsig::encoding::Preset, + C: Codec = varsig::encoding::Preset, > { pub varsig_header: V, pub payload: Payload, @@ -54,14 +54,12 @@ pub struct Delegation< pub struct Proof< DID: Did = did::preset::Verifier, V: varsig::Header = varsig::header::Preset, - C: Codec + TryFrom + Into = varsig::encoding::Preset, + C: Codec = varsig::encoding::Preset, > { pub prf: Vec>>, } -impl, C: Codec + TryFrom + Into> Capsule - for Proof -{ +impl, C: Codec> Capsule for Proof { const TAG: &'static str = "ucan/prf"; } @@ -124,8 +122,7 @@ impl, C: Codec> Delegation { } } -impl + Clone, C: Codec + TryFrom + Into> Envelope - for Delegation +impl + Clone, C: Codec> Envelope for Delegation where Payload: TryFrom>, Named: From>, @@ -165,8 +162,7 @@ where } } -impl + Clone, C: Codec + TryFrom + Into> Serialize - for Delegation +impl + Clone, C: Codec> Serialize for Delegation where Payload: TryFrom>, { @@ -178,8 +174,8 @@ where } } -impl<'de, DID: Did + Clone, V: varsig::Header + Clone, C: Codec + TryFrom + Into> - Deserialize<'de> for Delegation +impl<'de, DID: Did + Clone, V: varsig::Header + Clone, C: Codec> Deserialize<'de> + for Delegation where Payload: TryFrom>, as TryFrom>>::Error: std::fmt::Display, diff --git a/src/delegation/agent.rs b/src/delegation/agent.rs index 4fb8280c..1a81afc4 100644 --- a/src/delegation/agent.rs +++ b/src/delegation/agent.rs @@ -39,12 +39,8 @@ pub struct Agent< _marker: PhantomData<(V, C)>, } -impl< - S: Store + Clone, - DID: Did + Clone, - V: varsig::Header + Clone, - C: Codec + TryFrom + Into, - > Agent +impl + Clone, DID: Did + Clone, V: varsig::Header + Clone, C: Codec> + Agent where Ipld: Encode, Payload: TryFrom>, diff --git a/src/delegation/store/memory.rs b/src/delegation/store/memory.rs index 91fd6102..43260b00 100644 --- a/src/delegation/store/memory.rs +++ b/src/delegation/store/memory.rs @@ -78,7 +78,7 @@ use web_time::SystemTime; pub struct MemoryStore< DID: did::Did + Ord = did::preset::Verifier, V: varsig::Header = varsig::header::Preset, - C: Codec + TryFrom + Into = varsig::encoding::Preset, + C: Codec = varsig::encoding::Preset, > { inner: Arc>>, } @@ -87,16 +87,14 @@ pub struct MemoryStore< struct MemoryStoreInner< DID: did::Did + Ord = did::preset::Verifier, V: varsig::Header = varsig::header::Preset, - C: Codec + TryFrom + Into = varsig::encoding::Preset, + C: Codec = varsig::encoding::Preset, > { ucans: BTreeMap>>, index: BTreeMap, BTreeMap>>, revocations: BTreeSet, } -impl, C: Codec + TryFrom + Into> - MemoryStore -{ +impl, C: Codec> MemoryStore { pub fn new() -> Self { Self::default() } @@ -120,9 +118,7 @@ impl, C: Codec + TryFrom + Into, C: Codec + TryFrom + Into> Default - for MemoryStore -{ +impl, C: Codec> Default for MemoryStore { fn default() -> Self { Self { inner: Default::default(), @@ -130,9 +126,7 @@ impl, C: Codec + TryFrom + Into, C: Codec + TryFrom + Into> Default - for MemoryStoreInner -{ +impl, C: Codec> Default for MemoryStoreInner { fn default() -> Self { MemoryStoreInner { ucans: BTreeMap::new(), @@ -143,11 +137,8 @@ impl, C: Codec + TryFrom + Into> } // FIXME check that UCAN is valid -impl< - DID: Did + Ord + Clone, - V: varsig::Header + Clone, - Enc: Codec + TryFrom + Into, - > Store for MemoryStore +impl + Clone, Enc: Codec> Store + for MemoryStore where Named: From>, delegation::Payload: TryFrom>, diff --git a/src/delegation/store/traits.rs b/src/delegation/store/traits.rs index c5bc6701..f71cb5db 100644 --- a/src/delegation/store/traits.rs +++ b/src/delegation/store/traits.rs @@ -14,7 +14,7 @@ use std::{fmt::Debug, sync::Arc}; use thiserror::Error; use web_time::SystemTime; -pub trait Store + Clone, C: Codec + TryFrom + Into> +pub trait Store + Clone, C: Codec> where Ipld: Encode, Payload: TryFrom>, @@ -89,12 +89,8 @@ where } } -impl< - T: Store, - DID: Did + Clone, - V: varsig::Header + Clone, - C: Codec + TryFrom + Into, - > Store for &T +impl, DID: Did + Clone, V: varsig::Header + Clone, C: Codec> Store + for &T where Ipld: Encode, Payload: TryFrom>, diff --git a/src/invocation.rs b/src/invocation.rs index 4c486070..f9ffb106 100644 --- a/src/invocation.rs +++ b/src/invocation.rs @@ -54,7 +54,7 @@ pub struct Invocation< A, DID: did::Did = did::preset::Verifier, V: varsig::Header = varsig::header::Preset, - C: Codec + TryFrom + Into = varsig::encoding::Preset, + C: Codec = varsig::encoding::Preset, > { pub varsig_header: V, pub payload: Payload, @@ -66,7 +66,7 @@ impl< A: Clone + ToCommand + ParseAbility, DID: Clone + did::Did, V: Clone + varsig::Header, - C: Codec + TryFrom + Into, + C: Codec, > Encode for Invocation where Ipld: Encode, @@ -79,12 +79,8 @@ where } } -impl< - A: Clone + ToCommand + ParseAbility, - DID: Did + Clone, - V: varsig::Header, - C: Codec + TryFrom + Into, - > Invocation +impl, C: Codec> + Invocation where Ipld: Encode, { @@ -150,7 +146,7 @@ where } } -impl, C: Codec + TryFrom + Into> did::Verifiable +impl, C: Codec> did::Verifiable for Invocation { fn verifier(&self) -> &DID { @@ -162,7 +158,7 @@ impl< A: Clone + ToCommand + ParseAbility, DID: Did + Clone, V: varsig::Header + Clone, - C: Codec + TryFrom + Into, + C: Codec, > From> for Ipld where Named: From, @@ -177,7 +173,7 @@ impl< A: Clone + ToCommand + ParseAbility, DID: Did + Clone, V: varsig::Header + Clone, - C: Codec + TryFrom + Into, + C: Codec, > Envelope for Invocation where Named: From, @@ -222,7 +218,7 @@ impl< A: Clone + ToCommand + ParseAbility, DID: Did + Clone, V: varsig::Header + Clone, - C: Codec + TryFrom + Into, + C: Codec, > Serialize for Invocation where Named: From, @@ -241,7 +237,7 @@ impl< A: Clone + ToCommand + ParseAbility, DID: Did + Clone, V: varsig::Header + Clone, - C: Codec + TryFrom + Into, + C: Codec, > Deserialize<'de> for Invocation where Named: From, diff --git a/src/invocation/agent.rs b/src/invocation/agent.rs index 095c55ed..5862db3b 100644 --- a/src/invocation/agent.rs +++ b/src/invocation/agent.rs @@ -291,14 +291,8 @@ pub enum Recipient { } #[derive(Debug, Error, EnumAsInner)] -pub enum ReceiveError< - T, - DID: Did, - D, - S: Store, - V: varsig::Header, - C: Codec + TryFrom + Into, -> where +pub enum ReceiveError, V: varsig::Header, C: Codec> +where >::InvocationStoreError: fmt::Debug, { #[error("couldn't find delegation: {0}")] diff --git a/src/invocation/store/memory.rs b/src/invocation/store/memory.rs index 4b0a9f3f..083624df 100644 --- a/src/invocation/store/memory.rs +++ b/src/invocation/store/memory.rs @@ -9,7 +9,7 @@ pub struct MemoryStore< T = crate::ability::preset::Preset, DID: crate::did::Did = crate::did::preset::Verifier, V: varsig::Header = varsig::header::Preset, - C: Codec + TryFrom + Into = varsig::encoding::Preset, + C: Codec = varsig::encoding::Preset, > { inner: Arc>>, } @@ -19,7 +19,7 @@ pub struct MemoryStoreInner< T = crate::ability::preset::Preset, DID: crate::did::Did = crate::did::preset::Verifier, V: varsig::Header = varsig::header::Preset, - C: Codec + TryFrom + Into = varsig::encoding::Preset, + C: Codec = varsig::encoding::Preset, > { store: BTreeMap>>, } diff --git a/src/receipt.rs b/src/receipt.rs index a8837f98..abf1d38c 100644 --- a/src/receipt.rs +++ b/src/receipt.rs @@ -37,20 +37,16 @@ pub struct Receipt< _marker: std::marker::PhantomData, } -impl, C: Codec + TryFrom + Into> - did::Verifiable for Receipt +impl, C: Codec> did::Verifiable + for Receipt { fn verifier(&self) -> &DID { &self.payload.verifier() } } -impl< - T: Responds + Clone, - DID: Did + Clone, - V: varsig::Header + Clone, - C: Codec + TryFrom + Into, - > From> for Ipld +impl + Clone, C: Codec> + From> for Ipld where Ipld: From, Payload: TryFrom>, @@ -60,12 +56,8 @@ where } } -impl< - T: Responds + Clone, - DID: Did + Clone, - V: varsig::Header + Clone, - C: Codec + TryFrom + Into, - > Envelope for Receipt +impl + Clone, C: Codec> Envelope + for Receipt where Ipld: From, Payload: TryFrom>, @@ -105,12 +97,8 @@ where } } -impl< - T: Responds + Clone, - DID: Did + Clone, - V: varsig::Header + Clone, - C: Codec + TryFrom + Into, - > Serialize for Receipt +impl + Clone, C: Codec> Serialize + for Receipt where Ipld: From, Payload: TryFrom>, @@ -123,13 +111,8 @@ where } } -impl< - 'de, - T: Responds + Clone, - DID: Did + Clone, - V: varsig::Header + Clone, - C: Codec + TryFrom + Into, - > Deserialize<'de> for Receipt +impl<'de, T: Responds + Clone, DID: Did + Clone, V: varsig::Header + Clone, C: Codec> + Deserialize<'de> for Receipt where Ipld: From, Payload: TryFrom>, From 88ce308003be8803e6afaa7c21f261fe59b01c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Tue, 26 Mar 2024 15:18:11 +0100 Subject: [PATCH 4/4] refactor: Remove unused constraint, make `type InvocationStoreError: Debug` --- src/invocation/agent.rs | 7 +------ src/invocation/store/traits.rs | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/invocation/agent.rs b/src/invocation/agent.rs index 5862db3b..43d8b26c 100644 --- a/src/invocation/agent.rs +++ b/src/invocation/agent.rs @@ -68,8 +68,6 @@ where D: delegation::store::Store, V: varsig::Header + Clone, C: Codec, - >::InvocationStoreError: fmt::Debug, - >::DelegationStoreError: fmt::Debug, delegation::Payload: TryFrom>, Named: From>, { @@ -291,10 +289,7 @@ pub enum Recipient { } #[derive(Debug, Error, EnumAsInner)] -pub enum ReceiveError, V: varsig::Header, C: Codec> -where - >::InvocationStoreError: fmt::Debug, -{ +pub enum ReceiveError, V: varsig::Header, C: Codec> { #[error("couldn't find delegation: {0}")] DelegationNotFound(Cid), diff --git a/src/invocation/store/traits.rs b/src/invocation/store/traits.rs index 5af8d355..7442d449 100644 --- a/src/invocation/store/traits.rs +++ b/src/invocation/store/traits.rs @@ -1,9 +1,9 @@ use crate::{crypto::varsig, did::Did, invocation::Invocation}; use libipld_core::{cid::Cid, codec::Codec}; -use std::sync::Arc; +use std::{fmt::Debug, sync::Arc}; pub trait Store, C: Codec> { - type InvocationStoreError; + type InvocationStoreError: Debug; fn get( &self,