lair_keystore_api/lair_api/
get_entry.rs1use super::*;
2
3#[derive(Debug, serde::Serialize, serde::Deserialize)]
5#[serde(rename_all = "camelCase")]
6pub struct LairApiReqGetEntry {
7 pub msg_id: Arc<str>,
9
10 pub tag: Arc<str>,
12}
13
14impl LairApiReqGetEntry {
15 pub fn new(tag: Arc<str>) -> Self {
17 Self {
18 msg_id: new_msg_id(),
19 tag,
20 }
21 }
22}
23
24impl std::convert::TryFrom<LairApiEnum> for LairApiReqGetEntry {
25 type Error = one_err::OneErr;
26
27 fn try_from(e: LairApiEnum) -> Result<Self, Self::Error> {
28 if let LairApiEnum::ReqGetEntry(s) = e {
29 Ok(s)
30 } else {
31 Err(format!("Invalid response type: {e:?}").into())
32 }
33 }
34}
35
36impl AsLairCodec for LairApiReqGetEntry {
37 fn into_api_enum(self) -> LairApiEnum {
38 LairApiEnum::ReqGetEntry(self)
39 }
40}
41
42#[derive(Debug, serde::Serialize, serde::Deserialize)]
44#[serde(rename_all = "camelCase")]
45pub struct LairApiResGetEntry {
46 pub msg_id: Arc<str>,
48
49 pub entry_info: LairEntryInfo,
51}
52
53impl std::convert::TryFrom<LairApiEnum> for LairApiResGetEntry {
54 type Error = one_err::OneErr;
55
56 fn try_from(e: LairApiEnum) -> Result<Self, Self::Error> {
57 if let LairApiEnum::ResGetEntry(s) = e {
58 Ok(s)
59 } else {
60 Err(format!("Invalid response type: {e:?}").into())
61 }
62 }
63}
64
65impl AsLairCodec for LairApiResGetEntry {
66 fn into_api_enum(self) -> LairApiEnum {
67 LairApiEnum::ResGetEntry(self)
68 }
69}
70
71impl AsLairRequest for LairApiReqGetEntry {
72 type Response = LairApiResGetEntry;
73}
74
75impl AsLairResponse for LairApiResGetEntry {
76 type Request = LairApiReqGetEntry;
77}