Remove std::error::Error bounds from core
This commit is contained in:
parent
2be31d1b80
commit
ba3fa2ab8e
|
@ -100,7 +100,7 @@ pub enum AwcError<E: std::error::Error + Send> {
|
|||
SignatureError(#[from] SignatureError<E>),
|
||||
}
|
||||
|
||||
type SignError<S> = <<S as PrivateKey>::Signer as Sign>::Error;
|
||||
type SignTraitError<S> = <<S as PrivateKey>::Signer as Sign>::Error;
|
||||
|
||||
struct DigestWrapper<D>(D);
|
||||
|
||||
|
@ -123,6 +123,7 @@ where
|
|||
impl<Crypto> AwcClient<Crypto>
|
||||
where
|
||||
Crypto: PrivateKey,
|
||||
SignTraitError<Crypto>: std::error::Error,
|
||||
{
|
||||
/// Creates a new Client and Repo implementation backed by awc
|
||||
pub fn new(client: Client, config: SignatureConfig, crypto: Crypto) -> Self {
|
||||
|
@ -136,7 +137,7 @@ where
|
|||
async fn do_fetch<Id: Dereference>(
|
||||
&self,
|
||||
url: &Url,
|
||||
) -> Result<Option<<Id as Dereference>::Output>, AwcError<SignError<Crypto>>> {
|
||||
) -> Result<Option<<Id as Dereference>::Output>, AwcError<SignTraitError<Crypto>>> {
|
||||
let mut response = self
|
||||
.client
|
||||
.get(url.as_str())
|
||||
|
@ -160,8 +161,9 @@ where
|
|||
impl<Crypto> Repo for AwcClient<Crypto>
|
||||
where
|
||||
Crypto: PrivateKey,
|
||||
SignTraitError<Crypto>: std::error::Error,
|
||||
{
|
||||
type Error = AwcError<SignError<Crypto>>;
|
||||
type Error = AwcError<SignTraitError<Crypto>>;
|
||||
|
||||
async fn fetch<D: Dereference, S: Session>(
|
||||
&self,
|
||||
|
@ -177,8 +179,9 @@ impl<Crypto> Deliver for AwcClient<Crypto>
|
|||
where
|
||||
Crypto: DigestFactory + PrivateKey,
|
||||
<Crypto as DigestFactory>::Digest: DigestBuilder + Clone,
|
||||
SignTraitError<Crypto>: std::error::Error,
|
||||
{
|
||||
type Error = AwcError<SignError<Crypto>>;
|
||||
type Error = AwcError<SignTraitError<Crypto>>;
|
||||
|
||||
async fn deliver<T: serde::ser::Serialize, S: Session>(
|
||||
&self,
|
||||
|
|
|
@ -30,7 +30,7 @@ use crate::session::Session;
|
|||
#[async_trait::async_trait(?Send)]
|
||||
pub trait Deliver {
|
||||
/// Errors produced by the client
|
||||
type Error: std::error::Error + 'static;
|
||||
type Error: std::fmt::Display + 'static;
|
||||
|
||||
/// Deliver the activity to the inbox
|
||||
async fn deliver<T: serde::ser::Serialize, S: Session>(
|
||||
|
|
|
@ -36,7 +36,7 @@ use url::Url;
|
|||
#[async_trait::async_trait(?Send)]
|
||||
pub trait Repo {
|
||||
/// The Error produced by fetching an object
|
||||
type Error: std::error::Error;
|
||||
type Error: 'static;
|
||||
|
||||
/// Fetch the object from the repository
|
||||
async fn fetch<D: Dereference, S: Session>(
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::{rc::Rc, sync::Arc};
|
|||
/// This is used by downstream crates for creating HTTP Signatures.
|
||||
pub trait Sign {
|
||||
/// Errors that signing the request can produce
|
||||
type Error: std::error::Error + Send;
|
||||
type Error: Send;
|
||||
|
||||
/// Sign the given string, producing a String
|
||||
fn sign(&self, signing_string: &str) -> Result<String, Self::Error>;
|
||||
|
@ -28,7 +28,7 @@ pub trait PrivateKey {
|
|||
/// Describes building private keys
|
||||
pub trait PrivateKeyBuilder: PrivateKey {
|
||||
/// Errors possible when constructing private keys
|
||||
type Error: std::error::Error + Send;
|
||||
type Error: Send;
|
||||
|
||||
/// Build private key from pem pkcs8
|
||||
fn build(key_id: String, private_key_pem: &str) -> Result<Self, Self::Error>
|
||||
|
@ -39,7 +39,7 @@ pub trait PrivateKeyBuilder: PrivateKey {
|
|||
/// Describes verifying signatures
|
||||
pub trait Verify {
|
||||
/// Errors that verifying a signature can produce
|
||||
type Error: std::error::Error + Send;
|
||||
type Error: Send;
|
||||
|
||||
/// Verify the signature matches the provided signing string
|
||||
fn verify(&self, signing_string: &str, signature: &str) -> Result<bool, Self::Error>;
|
||||
|
|
|
@ -106,6 +106,7 @@ where
|
|||
impl<Crypto> ReqwestClient<Crypto>
|
||||
where
|
||||
Crypto: PrivateKey,
|
||||
SignTraitError<Crypto>: std::error::Error,
|
||||
{
|
||||
/// Create a new Client & Repo implementation backed by the reqwest client
|
||||
pub fn new(client: Client, config: SignatureConfig, crypto: Crypto) -> Self {
|
||||
|
@ -144,6 +145,7 @@ where
|
|||
impl<Crypto> Repo for ReqwestClient<Crypto>
|
||||
where
|
||||
Crypto: PrivateKey + Send + Sync,
|
||||
SignTraitError<Crypto>: std::error::Error,
|
||||
{
|
||||
type Error = ReqwestError<SignTraitError<Crypto>>;
|
||||
|
||||
|
@ -161,6 +163,7 @@ impl<Crypto> Deliver for ReqwestClient<Crypto>
|
|||
where
|
||||
Crypto: DigestFactory + PrivateKey + Send + Sync,
|
||||
<Crypto as DigestFactory>::Digest: DigestBuilder + Clone,
|
||||
SignTraitError<Crypto>: std::error::Error,
|
||||
{
|
||||
type Error = ReqwestError<SignTraitError<Crypto>>;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use apub::{
|
||||
repo::{Dereference, Repo},
|
||||
deliver::Activity,
|
||||
repo::{Dereference, Repo},
|
||||
session::Session,
|
||||
};
|
||||
use std::{
|
||||
|
@ -117,7 +117,7 @@ where
|
|||
where
|
||||
S: Session,
|
||||
R: Repo,
|
||||
R::Error: 'static,
|
||||
R::Error: std::error::Error + 'static,
|
||||
{
|
||||
Ok(repo.fetch(self, session).await?)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue