bitwarden_core/
uniffi_support.rs1use std::{num::NonZeroU32, str::FromStr};
4
5use bitwarden_crypto::{SymmetricCryptoKey, safe};
6use bitwarden_uniffi_error::convert_result;
7use uuid::Uuid;
8
9use crate::key_management::SignedSecurityState;
10
11uniffi::use_remote_type!(bitwarden_crypto::NonZeroU32);
12uniffi::use_remote_type!(bitwarden_crypto::safe::PasswordProtectedKeyEnvelope);
13uniffi::use_remote_type!(bitwarden_crypto::SymmetricCryptoKey);
14
15type DateTime = chrono::DateTime<chrono::Utc>;
16uniffi::custom_type!(DateTime, std::time::SystemTime, { remote });
17
18uniffi::custom_type!(Uuid, String, {
19 remote,
20 try_lift: |val| convert_result(Uuid::parse_str(&val)),
21 lower: |obj| obj.to_string(),
22});
23
24#[allow(dead_code)]
27#[derive(uniffi::Record)]
28struct UniffiConverterDummyRecord {
29 uuid: Uuid,
30 date: DateTime,
31}
32
33uniffi::custom_type!(SignedSecurityState, String, {
34 try_lift: |val| {
35 convert_result(SignedSecurityState::from_str(&val))
36 },
37 lower: |obj| obj.into(),
38});