Skip to main content

Crate xtax_encryption

Crate xtax_encryption 

Source
Expand description

§xtax-encryption

Trait-only encryption provider interface — no backend, no storage, no I/O decisions. Implement EncryptionProvider to plug any encryption scheme into crates like xtax-blob-storage.

§Crate architecture

xtax-encryption               ←  this crate (trait + error types only)
     ↑
xtax-blob-storage             ←  re-exports and uses the trait

§Usage

use async_trait::async_trait;
use tokio::io::{AsyncRead, AsyncWrite};
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>> {
        Ok(vec![])
    }

    async fn decrypt_stream(
        &self,
        _input: &mut (dyn AsyncRead + Send + Unpin),
        _output: &mut (dyn AsyncWrite + Send + Unpin),
        _header_bytes: &[u8],
    ) -> EncryptionResult<()> {
        Ok(())
    }

    async fn rekey_header(&self, _header_bytes: &[u8]) -> EncryptionResult<Option<Vec<u8>>> {
        Ok(None)
    }
}

§Feature flags

This crate has no features — it’s a minimal dependency.

Enums§

EncryptionError
An error returned by EncryptionProvider methods.

Traits§

EncryptionProvider
Encryption provider — abstracts the encryption operations needed by encrypted storage layers.

Type Aliases§

EncryptionResult
Convenience alias for Result<T, EncryptionError>.