pub struct Encryptor {
    data: Vec<u8>,
    context: CryptorContext,
    config: SensitiveInfoConfig,
}
Expand description

The Encryptor type. It contains data to be encrypted, plus context and config fields.

Fields§

§data: Vec<u8>

The actual bytes of data to be encrypted.

§context: CryptorContext

Additional context about the data.

§config: SensitiveInfoConfig

Configuration

Implementations§

source§

impl Encryptor

source

pub fn new( data: Vec<u8>, context: CryptorContext, config: SensitiveInfoConfig ) -> Self

Constructs a new instance of Encryptor type.

§Arguments
  • data - A vector of bytes representing the data to be managed by the instance.

  • context - An instance of CryptorContext that provides necessary cryptographic context for operations that may be performed on data.

  • config - A SensitiveInfoConfig instance that provides configuration details for managing sensitive information.

§Returns
  • Returns a new instance of Encryptor type, initialized with the provided data, context, and config.
§Example
let data = vec![1, 2, 3, 4, 5];
let context = CryptorContext::new(...);
let config = SensitiveInfoConfig::new(true);

let encryptor = Encryptor::new(data, context, config);
source

pub fn data(&self) -> &[u8]

Returns a reference to the encrypted data bytes stored within the Encryptor instance.

This method provides read-only access to the internal data field, ensuring that the encrypted data cannot be modified directly by the caller.

§Examples
// Assuming you've set up an `Encryptor` instance named `encryptor`
let data_bytes: &[u8] = encryptor.data();
§Returns

A byte slice (&[u8]) that represents the encrypted data. Returns a reference to the data bytes.

source

pub fn encrypt( self, rng: &mut (impl CryptoRng + RngCore), encryption_key: &CryptorKey ) -> Result<Decryptor, CryptoError>

Encrypts data using the provided encryption key.

§Arguments
  • rng - A mutable reference to the random number generator.
  • encryption_key - The key used to encrypt data.
§Returns
  • A new instance of the Encryptor
  • Returns an error of type [CryptoError] if the encryption process fails.

Trait Implementations§

source§

impl Clone for Encryptor

source§

fn clone(&self) -> Encryptor

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Encryptor

An implementation of the std::fmt::Debug trait for Encryptor

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Encryptor

An implementation of the std::fmt::Display trait for Encryptor

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Encryptor

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl PartialEq for Encryptor

Implement the PartialEq trait for the Encryptor type.

source§

fn eq(&self, other: &Self) -> bool

Determines if two Encryptor instances are equal.

This function compares the data and context fields of two Encryptor instances. It does not compare the config fields because the config field does not affect the functional equivalence of two Encryptor instances.

§Arguments
  • other - The other Encryptor instance to compare with.
§Returns

Returns true if the data and context fields are equal between the two Encryptor instances, Otherwise returns false.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<Encryptor> for Vec<u8>

Implementation of the TryFrom trait for converting to Vec<u8>

§

type Error = CryptoError

The type returned in the event of a conversion error.
source§

fn try_from(encryptor: Encryptor) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Vec<u8>> for Encryptor

Implementation of the TryFrom trait for converting from Vec<u8> to Encryptor

§

type Error = CryptoError

The type returned in the event of a conversion error.
source§

fn try_from(bytes: Vec<u8>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for Encryptor

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more