[][src]Struct data_vault::RedisDataVault

pub struct RedisDataVault<E, T> { /* fields omitted */ }

Use redis as a data vault back end

This implementation uses deadpool_redis

Connection setup is available as environment variables or a .env file with the following options: REDIS_URL=redis://127.0.0.1/ REDIS_POOL_MAX_SIZE=16

Examples

use data_vault::{DataVault, RedisDataVault};
use data_vault::encryption::AesGcmSivEncryption;
use data_vault::tokenizer::Blake3Tokenizer;
let data_vault = RedisDataVault::<AesGcmSivEncryption, Blake3Tokenizer>::new().unwrap();

Trait Implementations

impl<E, T> DataVault for RedisDataVault<E, T> where
    E: Encryption + Sync + Send,
    T: Tokenizer + Sync + Send
[src]

fn new() -> Result<Self, Box<dyn Error>>[src]

Create new RedisDataVault backend

examples

use data_vault::{DataVault, RedisDataVault};
use data_vault::encryption::AesGcmSivEncryption;
use data_vault::tokenizer::Blake3Tokenizer;
let data_vault = RedisDataVault::<AesGcmSivEncryption, Blake3Tokenizer>::new().unwrap();

fn store<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    token: &'life1 String,
    string: &'life2 String
) -> Pin<Box<dyn Future<Output = Result<(), PoolError>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

Encrypt and Store a string with the given token as the redis key Arguments: * CreditCard - the cc object that you wish to store return: the token as String

example

use data_vault::{DataVault, RedisDataVault};
use data_vault::encryption::AesGcmSivEncryption;
use data_vault::tokenizer::Blake3Tokenizer;

let token = String::from("abc123");
let credit_card_string = String::from("{number: 123}");
let data_vault = RedisDataVault::<AesGcmSivEncryption, Blake3Tokenizer>::new().unwrap();
data_vault.store(&token, &credit_card_string);

fn store_credit_card<'life0, 'life1, 'async_trait>(
    &'life0 self,
    credit_card: &'life1 CreditCard
) -> Pin<Box<dyn Future<Output = Result<String, PoolError>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Store the credit card in the data vault Arguments: * CreditCard - the cc object that you wish to store return: A new token as String

example

use data_vault::{DataVault, RedisDataVault};
use data_vault::encryption::AesGcmSivEncryption;
use data_vault::tokenizer::Blake3Tokenizer;
use credit_card::CreditCard;

let cc = CreditCard {
   number: "4111111111111111".to_string(),
   cardholder_name: "Graydon Hoare".to_string(),
   expiration_month: "01".to_string(),
   expiration_year: "2023".to_string(),
   brand: None,
   security_code: None
};

let data_vault = RedisDataVault::<AesGcmSivEncryption, Blake3Tokenizer>::new().unwrap();
let token = data_vault.store_credit_card(&cc);

fn retrieve<'life0, 'life1, 'async_trait>(
    &'life0 self,
    token: &'life1 String
) -> Pin<Box<dyn Future<Output = Result<String, PoolError>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Get decrypted arbitrary data from the vault by token Arguments: * token: the string form of the ID of the data returns: * the decrypted string of data

example

This example is not tested
use data_vault::DataVault;
use data_vault::RedisDataVault;
use data_vault::encryption::AesGcmSivEncryption;
use data_vault::tokenizer::Blake3Tokenizer;

let token = String::from("abc123");
let cc_string = String::from("{number: 123}");
let data_vault = RedisDataVault::<AesGcmSivEncryption, Blake3Tokenizer>::new().unwrap();
data_vault.store(&token, &cc_string).await;
let credit_card_string = data_vault.retrieve(&token)

fn retrieve_credit_card<'life0, 'life1, 'async_trait>(
    &'life0 self,
    token: &'life1 String
) -> Pin<Box<dyn Future<Output = Result<CreditCard, PoolError>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Get the credit card from the data vault given a token Arguments: * token: the string form of the ID of the data returns: * CreditCard object

Example

This example is not tested
use data_vault::DataVault;
use data_vault::RedisDataVault;
use data_vault::encryption::AesGcmSivEncryption;
use data_vault::tokenizer::Blake3Tokenizer;
use credit_card::CreditCard;

let cc = CreditCard {
   number: "4111111111111111".to_string(),
   cardholder_name: "Graydon Hoare".to_string(),
   expiration_month: "01".to_string(),
   expiration_year: "2023".to_string(),
   brand: None,
   security_code: None
};

let data_vault = RedisDataVault::<AesGcmSivEncryption, Blake3Tokenizer>::new().unwrap();
let token = data_vault.store_credit_card(&cc).await;
let credit_card = data_vault.retrieve_credit_card(&token).await;

Auto Trait Implementations

impl<E, T> !RefUnwindSafe for RedisDataVault<E, T>

impl<E, T> Send for RedisDataVault<E, T> where
    E: Send,
    T: Send

impl<E, T> Sync for RedisDataVault<E, T> where
    E: Sync,
    T: Sync

impl<E, T> Unpin for RedisDataVault<E, T> where
    E: Unpin,
    T: Unpin

impl<E, T> !UnwindSafe for RedisDataVault<E, T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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