pub struct FieldMapper { /* private fields */ }Expand description
Mapper for handling encrypted fields in database operations
Transparently encrypts/decrypts fields during read/write operations.
Implementations§
Source§impl FieldMapper
impl FieldMapper
Sourcepub fn new(
adapter: Arc<DatabaseFieldAdapter>,
encrypted_fields: Vec<String>,
) -> Self
pub fn new( adapter: Arc<DatabaseFieldAdapter>, encrypted_fields: Vec<String>, ) -> Self
Create new field mapper
§Arguments
adapter- Field adapter for encryption/decryptionencrypted_fields- List of fields that should be encrypted
Sourcepub fn is_field_encrypted(&self, field_name: &str) -> bool
pub fn is_field_encrypted(&self, field_name: &str) -> bool
Check if field is marked for encryption
Sourcepub async fn encrypt_field(
&self,
field_name: &str,
plaintext: &str,
) -> Result<Vec<u8>, SecretsError>
pub async fn encrypt_field( &self, field_name: &str, plaintext: &str, ) -> Result<Vec<u8>, SecretsError>
Sourcepub async fn decrypt_field(
&self,
field_name: &str,
ciphertext: &[u8],
) -> Result<String, SecretsError>
pub async fn decrypt_field( &self, field_name: &str, ciphertext: &[u8], ) -> Result<String, SecretsError>
Sourcepub async fn encrypt_fields(
&self,
fields: &[(String, String)],
) -> Result<Vec<FieldMapping>, SecretsError>
pub async fn encrypt_fields( &self, fields: &[(String, String)], ) -> Result<Vec<FieldMapping>, SecretsError>
Encrypt multiple fields (batch operation)
Returns FieldMapping objects with encryption status.
Sourcepub async fn decrypt_fields(
&self,
fields: &[(String, Vec<u8>)],
) -> Result<Vec<FieldMapping>, SecretsError>
pub async fn decrypt_fields( &self, fields: &[(String, Vec<u8>)], ) -> Result<Vec<FieldMapping>, SecretsError>
Decrypt multiple fields (batch operation)
Returns FieldMapping objects with decrypted values.
Sourcepub fn encrypted_fields(&self) -> Vec<String>
pub fn encrypted_fields(&self) -> Vec<String>
Get list of encrypted fields
Sourcepub fn has_encrypted_fields(&self) -> bool
pub fn has_encrypted_fields(&self) -> bool
Check if any fields are encrypted
Sourcepub fn register_encrypted_field(&mut self, field_name: impl Into<String>)
pub fn register_encrypted_field(&mut self, field_name: impl Into<String>)
Register field for encryption
Can be used to dynamically add encrypted fields after mapper creation.
Sourcepub fn unregister_encrypted_field(&mut self, field_name: &str)
pub fn unregister_encrypted_field(&mut self, field_name: &str)
Unregister field from encryption
Sourcepub fn encrypted_field_count(&self) -> usize
pub fn encrypted_field_count(&self) -> usize
Get count of encrypted fields
Sourcepub fn validate_configuration(&self) -> Result<(), SecretsError>
pub fn validate_configuration(&self) -> Result<(), SecretsError>
Validate field encryption configuration
Returns error if configuration is inconsistent or incomplete.
Auto Trait Implementations§
impl Freeze for FieldMapper
impl !RefUnwindSafe for FieldMapper
impl Send for FieldMapper
impl Sync for FieldMapper
impl Unpin for FieldMapper
impl !UnwindSafe for FieldMapper
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request