bitwarden_vault/cipher/
local_data.rs1use bitwarden_core::key_management::{KeyIds, SymmetricKeyId};
2use bitwarden_crypto::{CryptoError, Decryptable, Encryptable, KeyStoreContext};
3use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5#[cfg(feature = "wasm")]
6use tsify_next::Tsify;
7
8#[derive(Serialize, Deserialize, Debug, Clone)]
9#[serde(rename_all = "camelCase", deny_unknown_fields)]
10#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
11#[cfg_attr(feature = "wasm", derive(Tsify), tsify(into_wasm_abi, from_wasm_abi))]
12pub struct LocalData {
13 last_used_date: Option<DateTime<Utc>>,
14 last_launched: Option<DateTime<Utc>>,
15}
16
17#[derive(Serialize, Deserialize, Debug, Clone)]
18#[serde(rename_all = "camelCase", deny_unknown_fields)]
19#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
20#[cfg_attr(feature = "wasm", derive(Tsify), tsify(into_wasm_abi, from_wasm_abi))]
21pub struct LocalDataView {
22 last_used_date: Option<DateTime<Utc>>,
23 last_launched: Option<DateTime<Utc>>,
24}
25
26impl Encryptable<KeyIds, SymmetricKeyId, LocalData> for LocalDataView {
27 fn encrypt(
28 &self,
29 _ctx: &mut KeyStoreContext<KeyIds>,
30 _key: SymmetricKeyId,
31 ) -> Result<LocalData, CryptoError> {
32 Ok(LocalData {
33 last_used_date: self.last_used_date,
34 last_launched: self.last_launched,
35 })
36 }
37}
38
39impl Decryptable<KeyIds, SymmetricKeyId, LocalDataView> for LocalData {
40 fn decrypt(
41 &self,
42 _ctx: &mut KeyStoreContext<KeyIds>,
43 _key: SymmetricKeyId,
44 ) -> Result<LocalDataView, CryptoError> {
45 Ok(LocalDataView {
46 last_used_date: self.last_used_date,
47 last_launched: self.last_launched,
48 })
49 }
50}