pub struct MessageVerifier { /* private fields */ }Expand description
Signs messages using HMAC-SHA256.
Implementations§
Source§impl MessageVerifier
impl MessageVerifier
Sourcepub fn generate(&self, data: &[u8]) -> String
pub fn generate(&self, data: &[u8]) -> String
Generates a signed message in the form base64(payload)--base64(hmac).
Sourcepub fn generate_with_purpose(
&self,
data: &[u8],
purpose: &str,
expires_at: Option<DateTime<Utc>>,
) -> String
pub fn generate_with_purpose( &self, data: &[u8], purpose: &str, expires_at: Option<DateTime<Utc>>, ) -> String
Generates a signed message with purpose confinement and optional expiration.
Sourcepub fn verify(&self, signed_message: &str) -> Result<Vec<u8>, VerifierError>
pub fn verify(&self, signed_message: &str) -> Result<Vec<u8>, VerifierError>
Verifies a signed message and returns the original bytes.
Sourcepub fn verify_with_purpose(
&self,
signed_message: &str,
purpose: &str,
) -> Result<Vec<u8>, VerifierError>
pub fn verify_with_purpose( &self, signed_message: &str, purpose: &str, ) -> Result<Vec<u8>, VerifierError>
Verifies a signed message and enforces its purpose.
Sourcepub fn valid_message(&self, signed_message: &str) -> bool
pub fn valid_message(&self, signed_message: &str) -> bool
Returns true when the message has a valid signature.
Auto Trait Implementations§
impl Freeze for MessageVerifier
impl RefUnwindSafe for MessageVerifier
impl Send for MessageVerifier
impl Sync for MessageVerifier
impl Unpin for MessageVerifier
impl UnsafeUnpin for MessageVerifier
impl UnwindSafe for MessageVerifier
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more