[][src]Trait data_vault::DataVault

pub trait DataVault {
    fn new() -> Result<Self, Box<dyn Error>>
    where
        Self: Sized
;
#[must_use] 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
;
#[must_use] 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
;
#[must_use] 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
;
#[must_use] 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
; }

This is what a Data Vault can do It's fundamental purpose is to store and retrieve data in a secure encrypted manner

Required methods

fn new() -> Result<Self, Box<dyn Error>> where
    Self: Sized

#[must_use]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, 

#[must_use]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, 

#[must_use]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, 

#[must_use]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, 

Loading content...

Implementors

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;
Loading content...