bitwarden_core/
uniffi_support.rs

1//! This module contains custom type converters for Uniffi.
2
3use std::num::NonZeroU32;
4
5use uuid::Uuid;
6
7uniffi::use_remote_type!(bitwarden_crypto::NonZeroU32);
8
9type DateTime = chrono::DateTime<chrono::Utc>;
10uniffi::custom_type!(DateTime, std::time::SystemTime, { remote });
11
12uniffi::custom_type!(Uuid, String, {
13    remote,
14    try_lift: |val| Uuid::parse_str(val.as_str()).map_err(|e| e.into()),
15    lower: |obj| obj.to_string(),
16});
17
18// Uniffi doesn't emit unused types, this is a dummy record to ensure that the custom type
19// converters are emitted
20#[allow(dead_code)]
21#[derive(uniffi::Record)]
22struct UniffiConverterDummyRecord {
23    uuid: Uuid,
24    date: DateTime,
25}