lair_keystore_api/lair_api/
secret_box_xsalsa_open_by_tag.rs1use super::*;
2
3#[derive(Debug, serde::Serialize, serde::Deserialize)]
5#[serde(rename_all = "camelCase")]
6pub struct LairApiReqSecretBoxXSalsaOpenByTag {
7 pub msg_id: Arc<str>,
9
10 pub tag: Arc<str>,
12
13 #[serde(skip_serializing_if = "Option::is_none", default)]
16 pub deep_lock_passphrase: Option<SecretDataSized<64, 81>>,
17
18 pub nonce: [u8; 24],
20
21 pub cipher: Arc<[u8]>,
23}
24
25impl LairApiReqSecretBoxXSalsaOpenByTag {
26 pub fn new(
28 tag: Arc<str>,
29 deep_lock_passphrase: Option<SecretDataSized<64, 81>>,
30 nonce: [u8; 24],
31 cipher: Arc<[u8]>,
32 ) -> Self {
33 Self {
34 msg_id: new_msg_id(),
35 tag,
36 deep_lock_passphrase,
37 nonce,
38 cipher,
39 }
40 }
41}
42
43impl std::convert::TryFrom<LairApiEnum> for LairApiReqSecretBoxXSalsaOpenByTag {
44 type Error = one_err::OneErr;
45
46 fn try_from(e: LairApiEnum) -> Result<Self, Self::Error> {
47 if let LairApiEnum::ReqSecretBoxXSalsaOpenByTag(s) = e {
48 Ok(s)
49 } else {
50 Err(format!("Invalid response type: {e:?}").into())
51 }
52 }
53}
54
55impl AsLairCodec for LairApiReqSecretBoxXSalsaOpenByTag {
56 fn into_api_enum(self) -> LairApiEnum {
57 LairApiEnum::ReqSecretBoxXSalsaOpenByTag(self)
58 }
59}
60
61#[derive(Debug, serde::Serialize, serde::Deserialize)]
63#[serde(rename_all = "camelCase")]
64#[non_exhaustive]
65pub struct LairApiResSecretBoxXSalsaOpenByTag {
66 pub msg_id: Arc<str>,
68
69 pub message: Arc<[u8]>,
71}
72
73impl std::convert::TryFrom<LairApiEnum> for LairApiResSecretBoxXSalsaOpenByTag {
74 type Error = one_err::OneErr;
75
76 fn try_from(e: LairApiEnum) -> Result<Self, Self::Error> {
77 if let LairApiEnum::ResSecretBoxXSalsaOpenByTag(s) = e {
78 Ok(s)
79 } else {
80 Err(format!("Invalid response type: {e:?}").into())
81 }
82 }
83}
84
85impl AsLairCodec for LairApiResSecretBoxXSalsaOpenByTag {
86 fn into_api_enum(self) -> LairApiEnum {
87 LairApiEnum::ResSecretBoxXSalsaOpenByTag(self)
88 }
89}
90
91impl AsLairRequest for LairApiReqSecretBoxXSalsaOpenByTag {
92 type Response = LairApiResSecretBoxXSalsaOpenByTag;
93}
94
95impl AsLairResponse for LairApiResSecretBoxXSalsaOpenByTag {
96 type Request = LairApiReqSecretBoxXSalsaOpenByTag;
97}