bitwarden_vault/
domain.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use bitwarden_core::require;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::VaultParseError;

#[derive(Serialize, Deserialize, Debug, JsonSchema)]
pub struct GlobalDomains {
    pub r#type: i32,
    pub domains: Vec<String>,
    pub excluded: bool,
}

impl TryFrom<bitwarden_api_api::models::GlobalDomains> for GlobalDomains {
    type Error = VaultParseError;

    fn try_from(
        global_domains: bitwarden_api_api::models::GlobalDomains,
    ) -> Result<Self, Self::Error> {
        Ok(Self {
            r#type: require!(global_domains.r#type),
            domains: require!(global_domains.domains),
            excluded: require!(global_domains.excluded),
        })
    }
}