dfns_sdk_rs/models/
generic.rs1use crate::signer::CredentialSigner;
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7pub struct DfnsBaseApiOptions {
8 pub app_id: String,
9 #[serde(skip_serializing_if = "Option::is_none")]
10 pub auth_token: Option<String>,
11 #[serde(skip_serializing_if = "Option::is_none")]
12 pub base_url: Option<String>,
13 #[serde(skip_serializing_if = "Option::is_none")]
14 pub app_secret: Option<String>,
15}
16
17#[derive(serde::Serialize, serde::Deserialize)]
18pub struct DfnsApiClientOptions {
19 pub base: DfnsBaseApiOptions,
20 #[serde(skip)]
21 pub signer: Option<Box<dyn CredentialSigner>>,
22}
23
24impl std::fmt::Debug for DfnsApiClientOptions {
25 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26 f.debug_struct("DfnsApiClientOptions")
27 .field("base", &self.base)
28 .field("signer", &"<dyn CredentialSigner>")
29 .finish()
30 }
31}
32
33impl Clone for DfnsApiClientOptions {
34 fn clone(&self) -> Self {
35 Self {
36 base: self.base.clone(),
37 signer: None,
38 }
39 }
40}
41
42impl PartialEq for DfnsApiClientOptions {
43 fn eq(&self, other: &Self) -> bool {
44 self.base == other.base
45 }
46}
47
48impl DfnsApiClientOptions {
49 pub fn new(base: DfnsBaseApiOptions) -> Self {
50 Self { base, signer: None }
51 }
52
53 pub fn with_signer(mut self, signer: Box<dyn CredentialSigner>) -> Self {
54 self.signer = Some(signer);
55 self
56 }
57}