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