core_crypto_ffi/
crl.rs

1#[cfg(target_family = "wasm")]
2use wasm_bindgen::prelude::*;
3
4#[derive(Debug, Clone, derive_more::From, derive_more::Into)]
5#[cfg_attr(target_family = "wasm", wasm_bindgen, derive(serde::Serialize, serde::Deserialize))]
6pub struct NewCrlDistributionPoints(Option<Vec<String>>);
7
8#[cfg(not(target_family = "wasm"))]
9uniffi::custom_newtype!(NewCrlDistributionPoints, Option<Vec<String>>);
10
11#[cfg(target_family = "wasm")]
12#[wasm_bindgen]
13impl NewCrlDistributionPoints {
14    pub fn as_strings(&self) -> Option<Vec<String>> {
15        self.0.as_ref().map(|p| p.iter().map(Clone::clone).collect())
16    }
17}
18
19impl From<core_crypto::e2e_identity::NewCrlDistributionPoints> for NewCrlDistributionPoints {
20    fn from(value: core_crypto::e2e_identity::NewCrlDistributionPoints) -> Self {
21        let value = value.into_iter().collect::<Vec<_>>();
22        let value = (!value.is_empty()).then_some(value);
23        Self(value)
24    }
25}
26
27#[derive(Debug, Clone, Copy, PartialEq, Eq)]
28#[cfg_attr(target_family = "wasm", wasm_bindgen, derive(serde::Serialize, serde::Deserialize))]
29#[cfg_attr(not(target_family = "wasm"), derive(uniffi::Record))]
30/// Supporting struct for CRL registration result
31pub struct CrlRegistration {
32    /// Whether this CRL modifies the old CRL (i.e. has a different revocated cert list)
33    pub dirty: bool,
34    /// Optional expiration timestamp
35    pub expiration: Option<u64>,
36}
37
38impl From<core_crypto::e2e_identity::CrlRegistration> for CrlRegistration {
39    fn from(value: core_crypto::e2e_identity::CrlRegistration) -> Self {
40        Self {
41            dirty: value.dirty,
42            expiration: value.expiration,
43        }
44    }
45}
46
47#[cfg(target_family = "wasm")]
48#[wasm_bindgen]
49impl CrlRegistration {
50    #[wasm_bindgen(constructor)]
51    pub fn new(dirty: bool, expiration: Option<u64>) -> Self {
52        Self { dirty, expiration }
53    }
54}