-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '04-05-add_identity_update_builder' of github.com:xmtp/l…
…ibxmtp into 04-05-add_identity_update_builder
- Loading branch information
Showing
3 changed files
with
37 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use thiserror::Error; | ||
|
||
use super::{MemberIdentifier, Signature, SignatureKind}; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum SignerError { | ||
#[error("Signature error {0}")] | ||
Generic(String), | ||
} | ||
|
||
#[async_trait::async_trait] | ||
pub trait Signer: SignerClone { | ||
fn signer_identity(&self) -> MemberIdentifier; | ||
fn signature_kind(&self) -> SignatureKind; | ||
fn sign(&self, text: &str) -> Result<Box<dyn Signature>, SignerError>; | ||
} | ||
|
||
pub trait SignerClone { | ||
fn clone_box(&self) -> Box<dyn Signer>; | ||
} | ||
|
||
impl<T> SignerClone for T | ||
where | ||
T: 'static + Signer + Clone, | ||
{ | ||
fn clone_box(&self) -> Box<dyn Signer> { | ||
Box::new(self.clone()) | ||
} | ||
} | ||
|
||
impl Clone for Box<dyn Signer> { | ||
fn clone(&self) -> Box<dyn Signer> { | ||
self.clone_box() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters