1#![warn(missing_docs)]
2use super::openiap::{Envelope, RegisterQueueRequest, UnRegisterQueueRequest, RegisterExchangeRequest,
3 WatchRequest, UnWatchRequest, QueueMessageRequest
4};
5
6impl RegisterQueueRequest {
7 pub fn byqueuename(queuename: &str) -> Self {
9 Self {
10 queuename: queuename.to_string()
11 }
12 }
13 pub fn to_envelope(&self) -> Envelope {
15 let any_message = prost_types::Any {
16 type_url: "type.googleapis.com/openiap.RegisterQueueRequest".to_string(),
17 value: {
18 let mut buf = Vec::new();
19 prost::Message::encode(self, &mut buf).unwrap_or(());
20 buf
21 },
22 };
23 Envelope {
24 command: "registerqueue".into(),
25 data: Some(any_message.clone()),
26 ..Default::default()
27 }
28 }
29}
30impl RegisterExchangeRequest {
31 pub fn byexchangename(exchangename: &str) -> Self {
33 Self {
34 exchangename: exchangename.to_string(),
35 addqueue: true,
36 ..Default::default()
37 }
38 }
39 pub fn to_envelope(&self) -> Envelope {
41 let any_message = prost_types::Any {
42 type_url: "type.googleapis.com/openiap.RegisterExchangeRequest".to_string(),
43 value: {
44 let mut buf = Vec::new();
45 prost::Message::encode(self, &mut buf).unwrap_or(());
46 buf
47 },
48 };
49 Envelope {
50 command: "registerexchange".into(),
51 data: Some(any_message.clone()),
52 ..Default::default()
53 }
54 }
55}
56impl UnRegisterQueueRequest {
57 pub fn byqueuename(queuename: &str) -> Self {
59 Self {
60 queuename: queuename.to_string()
61 }
62 }
63 pub fn to_envelope(&self) -> Envelope {
65 let any_message = prost_types::Any {
66 type_url: "type.googleapis.com/openiap.UnRegisterQueueRequest".to_string(),
67 value: {
68 let mut buf = Vec::new();
69 prost::Message::encode(self, &mut buf).unwrap_or(());
70 buf
71 },
72 };
73 Envelope {
74 command: "unregisterqueue".into(),
75 data: Some(any_message.clone()),
76 ..Default::default()
77 }
78 }
79
80}
81impl WatchRequest {
82 pub fn new(collectionname: &str, paths: Vec<String>) -> Self {
84 Self {
85 collectionname: collectionname.to_string(),
86 paths
87 }
88 }
89 pub fn to_envelope(&self) -> Envelope {
91 let any_message = prost_types::Any {
92 type_url: "type.googleapis.com/openiap.WatchRequest".to_string(),
93 value: {
94 let mut buf = Vec::new();
95 prost::Message::encode(self, &mut buf).unwrap_or(());
96 buf
97 },
98 };
99 Envelope {
100 command: "watch".into(),
101 data: Some(any_message.clone()),
102 ..Default::default()
103 }
104 }
105}
106impl UnWatchRequest {
107 pub fn byid(id: &str) -> Self {
109 Self {
110 id: id.to_string()
111 }
112 }
113 pub fn to_envelope(&self) -> Envelope {
115 let any_message = prost_types::Any {
116 type_url: "type.googleapis.com/openiap.UnWatchRequest".to_string(),
117 value: {
118 let mut buf = Vec::new();
119 prost::Message::encode(self, &mut buf).unwrap_or(());
120 buf
121 },
122 };
123 Envelope {
124 command: "unwatch".into(),
125 data: Some(any_message.clone()),
126 ..Default::default()
127 }
128 }
129}
130impl QueueMessageRequest {
131 pub fn byqueuename(queuename: &str, data: &str, striptoken: bool) -> Self {
133 Self {
134 queuename: queuename.to_string(),
135 data: data.to_string(),
136 striptoken,
137 ..Default::default()
138 }
139 }
140 pub fn replyto(queuename: &str, correlation_id: &str, data: &str, striptoken: bool) -> Self {
142 Self {
143 queuename: queuename.to_string(),
144 data: data.to_string(),
145 correlation_id: correlation_id.to_string(),
146 striptoken,
147 ..Default::default()
148 }
149 }
150 pub fn byexchangename(exchangename: &str, data: &str, striptoken: bool) -> Self {
152 Self {
153 exchangename: exchangename.to_string(),
154 data: data.to_string(),
155 striptoken,
156 ..Default::default()
157 }
158 }
159 pub fn to_envelope(&self) -> Envelope {
161 let any_message = prost_types::Any {
162 type_url: "type.googleapis.com/openiap.QueueMessageRequest".to_string(),
163 value: {
164 let mut buf = Vec::new();
165 prost::Message::encode(self, &mut buf).unwrap_or(());
166 buf
167 },
168 };
169 Envelope {
170 command: "queuemessage".into(),
171 data: Some(any_message.clone()),
172 ..Default::default()
173 }
174 }
175}