[−][src]Struct data_vault::RedisDataVault
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::{RedisDataVault, DataVault}; let data_vault = RedisDataVault::new();
Panics
Will panic when connection can not be made
Trait Implementations
impl DataVault for RedisDataVault
[src]
fn new() -> Self
[src]
Create new RedisDataVault backend
examples
use data_vault::DataVault; use data_vault::RedisDataVault; let rdv = RedisDataVault::new();
fn store<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
token: &'life1 String,
string: &'life2 String
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
token: &'life1 String,
string: &'life2 String
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
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; use data_vault::RedisDataVault; let token = String::from("abc123"); let credit_card_string = String::from("{number: 123}"); let rdv = RedisDataVault::new(); rdv.store(&token, &credit_card_string);
fn store_credit_card<'life0, 'life1, 'async_trait>(
&'life0 self,
credit_card: &'life1 CreditCard
) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
credit_card: &'life1 CreditCard
) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
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; use data_vault::RedisDataVault; 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 rdv = RedisDataVault::new(); let token = rdv.store_credit_card(&cc);
fn retrieve<'life0, 'life1, 'async_trait>(
&'life0 self,
token: &'life1 String
) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
token: &'life1 String
) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
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
use data_vault::DataVault; use data_vault::RedisDataVault; let token = String::from("abc123"); let cc_string = String::from("{number: 123}"); let rdv = RedisDataVault::new(); rdv.store(&token, &cc_string).await; let credit_card_string = rdv.retrieve(&token)
fn retrieve_credit_card<'life0, 'life1, 'async_trait>(
&'life0 self,
token: &'life1 String
) -> Pin<Box<dyn Future<Output = CreditCard> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
token: &'life1 String
) -> Pin<Box<dyn Future<Output = CreditCard> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
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
use data_vault::DataVault; use data_vault::RedisDataVault; 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 rdv = RedisDataVault::new(); let token = rdv.store_credit_card(&cc).await; let credit_card = rdv.retrieve_credit_card(&token).await;
Auto Trait Implementations
impl !RefUnwindSafe for RedisDataVault
impl Send for RedisDataVault
impl Sync for RedisDataVault
impl Unpin for RedisDataVault
impl !UnwindSafe for RedisDataVault
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,