core: simplify deliver lifetimes, add digest::build, verify::build

This commit is contained in:
Aode (lion) 2021-11-19 09:58:04 -06:00
parent ec1bf8640f
commit 1c7700c9a0
3 changed files with 7 additions and 9 deletions

View file

@ -5,9 +5,6 @@ pub trait Client<'a> {
type Error: std::error::Error + 'static;
type Future: Future<Output = Result<(), Self::Error>> + 'a;
fn deliver<'b, T: serde::ser::Serialize>(
&'b self,
inbox: &'a Url,
activity: &'a T,
) -> Self::Future;
fn deliver<T: serde::ser::Serialize>(&'a self, inbox: &'a Url, activity: &'a T)
-> Self::Future;
}

View file

@ -1,11 +1,10 @@
pub trait Digest {
const NAME: &'static str;
fn build() -> Self;
fn digest(self, input: &[u8]) -> String;
}
pub trait DigestFactory {
type Digest: Digest + Send;
fn digest(&self) -> Self::Digest;
}

View file

@ -17,11 +17,13 @@ pub trait SignFactory {
pub trait Verify {
type Error: std::error::Error + Send;
fn build(public_key_pem: &str) -> Result<Self, Self::Error>
where
Self: Sized;
fn verify(&self, signing_string: &str, signature: &str) -> Result<bool, Self::Error>;
}
pub trait VerifyFactory {
type Verifier: Verify + Send + 'static;
fn verifier(&self, public_key_pem: String) -> Self::Verifier;
}