pub struct RotatingEncryptor { /* private fields */ }Expand description
Tries multiple encryptors until one succeeds.
Implementations§
Source§impl RotatingEncryptor
impl RotatingEncryptor
Sourcepub fn new(encryptors: Vec<MessageEncryptor>) -> Self
pub fn new(encryptors: Vec<MessageEncryptor>) -> Self
Creates a rotating encryptor with the newest encryptor first.
Sourcepub fn encrypt_and_sign(&self, data: &[u8]) -> Result<String, EncryptorError>
pub fn encrypt_and_sign(&self, data: &[u8]) -> Result<String, EncryptorError>
Encrypts with the newest encryptor.
Sourcepub fn encrypt_and_sign_with_purpose(
&self,
data: &[u8],
purpose: &str,
expires_at: Option<DateTime<Utc>>,
) -> Result<String, EncryptorError>
pub fn encrypt_and_sign_with_purpose( &self, data: &[u8], purpose: &str, expires_at: Option<DateTime<Utc>>, ) -> Result<String, EncryptorError>
Encrypts with purpose using the newest encryptor.
Sourcepub fn decrypt_and_verify(
&self,
encrypted_message: &str,
) -> Result<Vec<u8>, EncryptorError>
pub fn decrypt_and_verify( &self, encrypted_message: &str, ) -> Result<Vec<u8>, EncryptorError>
Decrypts with all configured encryptors.
Sourcepub fn decrypt_and_verify_with_purpose(
&self,
encrypted_message: &str,
purpose: &str,
) -> Result<Vec<u8>, EncryptorError>
pub fn decrypt_and_verify_with_purpose( &self, encrypted_message: &str, purpose: &str, ) -> Result<Vec<u8>, EncryptorError>
Decrypts with purpose using all configured encryptors.
Auto Trait Implementations§
impl Freeze for RotatingEncryptor
impl RefUnwindSafe for RotatingEncryptor
impl Send for RotatingEncryptor
impl Sync for RotatingEncryptor
impl Unpin for RotatingEncryptor
impl UnsafeUnpin for RotatingEncryptor
impl UnwindSafe for RotatingEncryptor
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