pub trait EncryptedDataStore: Default + Serialize {
// Provided methods
fn open<P>(db: P, password: &str) -> Result<EncryptedAtomicDatabase<Self>>
where P: AsRef<Path>,
Self: DeserializeOwned { ... }
fn create_from_str<P>(
data: &str,
path: P,
password: &str,
) -> Result<EncryptedAtomicDatabase<Self>>
where P: AsRef<Path>,
Self: DeserializeOwned { ... }
fn load_encrypted(
file: &mut impl Read,
key: &Key<Aes256Gcm>,
) -> Result<Self>
where Self: DeserializeOwned { ... }
fn save_encrypted(
&self,
file: impl Write,
key: &Key<Aes256Gcm>,
salt: [u8; 16],
) -> Result<usize> { ... }
fn encrypt(
&self,
key: &Key<Aes256Gcm>,
salt: [u8; 16],
) -> Result<EncryptedData> { ... }
fn decrypt(encrypted: &EncryptedData, key: &Key<Aes256Gcm>) -> Result<Self>
where Self: DeserializeOwned { ... }
}Expand description
This trait needs to be implemented for the Database struct. It requires a few implementations. The defined functions have default implementations.
Provided Methods§
Sourcefn open<P>(db: P, password: &str) -> Result<EncryptedAtomicDatabase<Self>>
fn open<P>(db: P, password: &str) -> Result<EncryptedAtomicDatabase<Self>>
Opens a Database by the specified path and password. If the Database doesn’t exist,
this will create a new one! Wrap a Arc<_> around it to use it in parallel contexts!
fn create_from_str<P>( data: &str, path: P, password: &str, ) -> Result<EncryptedAtomicDatabase<Self>>
Sourcefn load_encrypted(file: &mut impl Read, key: &Key<Aes256Gcm>) -> Result<Self>where
Self: DeserializeOwned,
fn load_encrypted(file: &mut impl Read, key: &Key<Aes256Gcm>) -> Result<Self>where
Self: DeserializeOwned,
Loads the database after decrypting it from file.
Sourcefn save_encrypted(
&self,
file: impl Write,
key: &Key<Aes256Gcm>,
salt: [u8; 16],
) -> Result<usize>
fn save_encrypted( &self, file: impl Write, key: &Key<Aes256Gcm>, salt: [u8; 16], ) -> Result<usize>
Encrypts and safes the database to the file.
Sourcefn encrypt(&self, key: &Key<Aes256Gcm>, salt: [u8; 16]) -> Result<EncryptedData>
fn encrypt(&self, key: &Key<Aes256Gcm>, salt: [u8; 16]) -> Result<EncryptedData>
Encrypts the current data and returns the encrypted data.
Sourcefn decrypt(encrypted: &EncryptedData, key: &Key<Aes256Gcm>) -> Result<Self>where
Self: DeserializeOwned,
fn decrypt(encrypted: &EncryptedData, key: &Key<Aes256Gcm>) -> Result<Self>where
Self: DeserializeOwned,
Decrypts the encrypted data using the given key and returns the decrypted data.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.