#[non_exhaustive]pub enum EncryptionError {
Operation {
message: String,
source: Option<Box<dyn Error + Sync + Send>>,
},
InvalidHeader(String),
Io(Error),
}Expand description
Encryption provider — abstracts the encryption operations needed
by EncryptedBlobStore.
This trait allows the blob store to work with any encryption backend that supports detached-header stream encryption.
For full documentation see the Encryption guide.
§Example (custom provider)
use async_trait::async_trait;
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, AsyncReadExt};
use xtax_encryption::{EncryptionProvider, EncryptionResult};
struct NoopEncryption;
#[async_trait]
impl EncryptionProvider for NoopEncryption {
async fn encrypt_stream(
&self,
input: &mut (dyn AsyncRead + Send + Unpin),
output: &mut (dyn AsyncWrite + Send + Unpin),
) -> EncryptionResult<Vec<u8>> {
let mut buf = Vec::new();
input.read_to_end(&mut buf).await.unwrap();
output.write_all(&buf).await.unwrap();
Ok(vec![])
}
async fn decrypt_stream(
&self,
input: &mut (dyn AsyncRead + Send + Unpin),
output: &mut (dyn AsyncWrite + Send + Unpin),
_header_bytes: &[u8],
) -> EncryptionResult<()> {
let mut buf = Vec::new();
input.read_to_end(&mut buf).await.unwrap();
output.write_all(&buf).await.unwrap();
Ok(())
}
async fn rekey_header(&self, _header_bytes: &[u8]) -> EncryptionResult<Option<Vec<u8>>> {
Ok(None)
}
}An error returned by EncryptionProvider methods.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Operation
Encrypt or decrypt operation failed.
Fields
InvalidHeader(String)
Invalid or corrupted header data.
Io(Error)
I/O error during encryption or decryption.
Trait Implementations§
Source§impl Debug for EncryptionError
impl Debug for EncryptionError
Source§impl Display for EncryptionError
impl Display for EncryptionError
Source§impl Error for EncryptionError
impl Error for EncryptionError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<EncryptionError> for BlobStorageError
impl From<EncryptionError> for BlobStorageError
Source§fn from(e: EncryptionError) -> Self
fn from(e: EncryptionError) -> Self
Converts to this type from the input type.
Source§impl From<Error> for EncryptionError
impl From<Error> for EncryptionError
Source§fn from(source: Error) -> EncryptionError
fn from(source: Error) -> EncryptionError
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for EncryptionError
impl !UnwindSafe for EncryptionError
impl Freeze for EncryptionError
impl Send for EncryptionError
impl Sync for EncryptionError
impl Unpin for EncryptionError
impl UnsafeUnpin for EncryptionError
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 moreCreates a shared type from an unshared type.