1#![allow(non_snake_case)]
4#![allow(non_upper_case_globals)]
5#![allow(non_camel_case_types)]
6#![allow(unused_imports)]
7#![allow(unknown_lints)]
8#![allow(clippy::all)]
9#![cfg_attr(rustfmt, rustfmt_skip)]
10
11
12use quick_protobuf::{MessageInfo, MessageRead, MessageWrite, BytesReader, Writer, WriterBackend, Result};
13use quick_protobuf::sizeofs::*;
14use super::super::*;
15
16#[allow(clippy::derive_partial_eq_without_eq)]
17#[derive(Debug, Default, PartialEq, Clone)]
18pub struct RPC {
19 pub subscriptions: Vec<gossipsub::pb::mod_RPC::SubOpts>,
20 pub publish: Vec<gossipsub::pb::Message>,
21 pub control: Option<gossipsub::pb::ControlMessage>,
22}
23
24impl<'a> MessageRead<'a> for RPC {
25 fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
26 let mut msg = Self::default();
27 while !r.is_eof() {
28 match r.next_tag(bytes) {
29 Ok(10) => msg.subscriptions.push(r.read_message::<gossipsub::pb::mod_RPC::SubOpts>(bytes)?),
30 Ok(18) => msg.publish.push(r.read_message::<gossipsub::pb::Message>(bytes)?),
31 Ok(26) => msg.control = Some(r.read_message::<gossipsub::pb::ControlMessage>(bytes)?),
32 Ok(t) => { r.read_unknown(bytes, t)?; }
33 Err(e) => return Err(e),
34 }
35 }
36 Ok(msg)
37 }
38}
39
40impl MessageWrite for RPC {
41 fn get_size(&self) -> usize {
42 0
43 + self.subscriptions.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
44 + self.publish.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
45 + self.control.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
46 }
47
48 fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
49 for s in &self.subscriptions { w.write_with_tag(10, |w| w.write_message(s))?; }
50 for s in &self.publish { w.write_with_tag(18, |w| w.write_message(s))?; }
51 if let Some(ref s) = self.control { w.write_with_tag(26, |w| w.write_message(s))?; }
52 Ok(())
53 }
54}
55
56pub mod mod_RPC {
57
58use super::*;
59
60#[allow(clippy::derive_partial_eq_without_eq)]
61#[derive(Debug, Default, PartialEq, Clone)]
62pub struct SubOpts {
63 pub subscribe: Option<bool>,
64 pub topic_id: Option<String>,
65}
66
67impl<'a> MessageRead<'a> for SubOpts {
68 fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
69 let mut msg = Self::default();
70 while !r.is_eof() {
71 match r.next_tag(bytes) {
72 Ok(8) => msg.subscribe = Some(r.read_bool(bytes)?),
73 Ok(18) => msg.topic_id = Some(r.read_string(bytes)?.to_owned()),
74 Ok(t) => { r.read_unknown(bytes, t)?; }
75 Err(e) => return Err(e),
76 }
77 }
78 Ok(msg)
79 }
80}
81
82impl MessageWrite for SubOpts {
83 fn get_size(&self) -> usize {
84 0
85 + self.subscribe.as_ref().map_or(0, |m| 1 + sizeof_varint(*(m) as u64))
86 + self.topic_id.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
87 }
88
89 fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
90 if let Some(ref s) = self.subscribe { w.write_with_tag(8, |w| w.write_bool(*s))?; }
91 if let Some(ref s) = self.topic_id { w.write_with_tag(18, |w| w.write_string(&**s))?; }
92 Ok(())
93 }
94}
95
96}
97
98#[allow(clippy::derive_partial_eq_without_eq)]
99#[derive(Debug, Default, PartialEq, Clone)]
100pub struct Message {
101 pub from: Option<Vec<u8>>,
102 pub data: Option<Vec<u8>>,
103 pub seqno: Option<Vec<u8>>,
104 pub topic: String,
105 pub signature: Option<Vec<u8>>,
106 pub key: Option<Vec<u8>>,
107}
108
109impl<'a> MessageRead<'a> for Message {
110 fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
111 let mut msg = Self::default();
112 while !r.is_eof() {
113 match r.next_tag(bytes) {
114 Ok(10) => msg.from = Some(r.read_bytes(bytes)?.to_owned()),
115 Ok(18) => msg.data = Some(r.read_bytes(bytes)?.to_owned()),
116 Ok(26) => msg.seqno = Some(r.read_bytes(bytes)?.to_owned()),
117 Ok(34) => msg.topic = r.read_string(bytes)?.to_owned(),
118 Ok(42) => msg.signature = Some(r.read_bytes(bytes)?.to_owned()),
119 Ok(50) => msg.key = Some(r.read_bytes(bytes)?.to_owned()),
120 Ok(t) => { r.read_unknown(bytes, t)?; }
121 Err(e) => return Err(e),
122 }
123 }
124 Ok(msg)
125 }
126}
127
128impl MessageWrite for Message {
129 fn get_size(&self) -> usize {
130 0
131 + self.from.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
132 + self.data.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
133 + self.seqno.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
134 + 1 + sizeof_len((&self.topic).len())
135 + self.signature.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
136 + self.key.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
137 }
138
139 fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
140 if let Some(ref s) = self.from { w.write_with_tag(10, |w| w.write_bytes(&**s))?; }
141 if let Some(ref s) = self.data { w.write_with_tag(18, |w| w.write_bytes(&**s))?; }
142 if let Some(ref s) = self.seqno { w.write_with_tag(26, |w| w.write_bytes(&**s))?; }
143 w.write_with_tag(34, |w| w.write_string(&**&self.topic))?;
144 if let Some(ref s) = self.signature { w.write_with_tag(42, |w| w.write_bytes(&**s))?; }
145 if let Some(ref s) = self.key { w.write_with_tag(50, |w| w.write_bytes(&**s))?; }
146 Ok(())
147 }
148}
149
150#[allow(clippy::derive_partial_eq_without_eq)]
151#[derive(Debug, Default, PartialEq, Clone)]
152pub struct ControlMessage {
153 pub ihave: Vec<gossipsub::pb::ControlIHave>,
154 pub iwant: Vec<gossipsub::pb::ControlIWant>,
155 pub graft: Vec<gossipsub::pb::ControlGraft>,
156 pub prune: Vec<gossipsub::pb::ControlPrune>,
157 pub idontwant: Vec<gossipsub::pb::ControlIDontWant>,
158}
159
160impl<'a> MessageRead<'a> for ControlMessage {
161 fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
162 let mut msg = Self::default();
163 while !r.is_eof() {
164 match r.next_tag(bytes) {
165 Ok(10) => msg.ihave.push(r.read_message::<gossipsub::pb::ControlIHave>(bytes)?),
166 Ok(18) => msg.iwant.push(r.read_message::<gossipsub::pb::ControlIWant>(bytes)?),
167 Ok(26) => msg.graft.push(r.read_message::<gossipsub::pb::ControlGraft>(bytes)?),
168 Ok(34) => msg.prune.push(r.read_message::<gossipsub::pb::ControlPrune>(bytes)?),
169 Ok(42) => msg.idontwant.push(r.read_message::<gossipsub::pb::ControlIDontWant>(bytes)?),
170 Ok(t) => { r.read_unknown(bytes, t)?; }
171 Err(e) => return Err(e),
172 }
173 }
174 Ok(msg)
175 }
176}
177
178impl MessageWrite for ControlMessage {
179 fn get_size(&self) -> usize {
180 0
181 + self.ihave.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
182 + self.iwant.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
183 + self.graft.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
184 + self.prune.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
185 + self.idontwant.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
186 }
187
188 fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
189 for s in &self.ihave { w.write_with_tag(10, |w| w.write_message(s))?; }
190 for s in &self.iwant { w.write_with_tag(18, |w| w.write_message(s))?; }
191 for s in &self.graft { w.write_with_tag(26, |w| w.write_message(s))?; }
192 for s in &self.prune { w.write_with_tag(34, |w| w.write_message(s))?; }
193 for s in &self.idontwant { w.write_with_tag(42, |w| w.write_message(s))?; }
194 Ok(())
195 }
196}
197
198#[allow(clippy::derive_partial_eq_without_eq)]
199#[derive(Debug, Default, PartialEq, Clone)]
200pub struct ControlIHave {
201 pub topic_id: Option<String>,
202 pub message_ids: Vec<Vec<u8>>,
203}
204
205impl<'a> MessageRead<'a> for ControlIHave {
206 fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
207 let mut msg = Self::default();
208 while !r.is_eof() {
209 match r.next_tag(bytes) {
210 Ok(10) => msg.topic_id = Some(r.read_string(bytes)?.to_owned()),
211 Ok(18) => msg.message_ids.push(r.read_bytes(bytes)?.to_owned()),
212 Ok(t) => { r.read_unknown(bytes, t)?; }
213 Err(e) => return Err(e),
214 }
215 }
216 Ok(msg)
217 }
218}
219
220impl MessageWrite for ControlIHave {
221 fn get_size(&self) -> usize {
222 0
223 + self.topic_id.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
224 + self.message_ids.iter().map(|s| 1 + sizeof_len((s).len())).sum::<usize>()
225 }
226
227 fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
228 if let Some(ref s) = self.topic_id { w.write_with_tag(10, |w| w.write_string(&**s))?; }
229 for s in &self.message_ids { w.write_with_tag(18, |w| w.write_bytes(&**s))?; }
230 Ok(())
231 }
232}
233
234#[allow(clippy::derive_partial_eq_without_eq)]
235#[derive(Debug, Default, PartialEq, Clone)]
236pub struct ControlIWant {
237 pub message_ids: Vec<Vec<u8>>,
238}
239
240impl<'a> MessageRead<'a> for ControlIWant {
241 fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
242 let mut msg = Self::default();
243 while !r.is_eof() {
244 match r.next_tag(bytes) {
245 Ok(10) => msg.message_ids.push(r.read_bytes(bytes)?.to_owned()),
246 Ok(t) => { r.read_unknown(bytes, t)?; }
247 Err(e) => return Err(e),
248 }
249 }
250 Ok(msg)
251 }
252}
253
254impl MessageWrite for ControlIWant {
255 fn get_size(&self) -> usize {
256 0
257 + self.message_ids.iter().map(|s| 1 + sizeof_len((s).len())).sum::<usize>()
258 }
259
260 fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
261 for s in &self.message_ids { w.write_with_tag(10, |w| w.write_bytes(&**s))?; }
262 Ok(())
263 }
264}
265
266#[allow(clippy::derive_partial_eq_without_eq)]
267#[derive(Debug, Default, PartialEq, Clone)]
268pub struct ControlGraft {
269 pub topic_id: Option<String>,
270}
271
272impl<'a> MessageRead<'a> for ControlGraft {
273 fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
274 let mut msg = Self::default();
275 while !r.is_eof() {
276 match r.next_tag(bytes) {
277 Ok(10) => msg.topic_id = Some(r.read_string(bytes)?.to_owned()),
278 Ok(t) => { r.read_unknown(bytes, t)?; }
279 Err(e) => return Err(e),
280 }
281 }
282 Ok(msg)
283 }
284}
285
286impl MessageWrite for ControlGraft {
287 fn get_size(&self) -> usize {
288 0
289 + self.topic_id.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
290 }
291
292 fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
293 if let Some(ref s) = self.topic_id { w.write_with_tag(10, |w| w.write_string(&**s))?; }
294 Ok(())
295 }
296}
297
298#[allow(clippy::derive_partial_eq_without_eq)]
299#[derive(Debug, Default, PartialEq, Clone)]
300pub struct ControlPrune {
301 pub topic_id: Option<String>,
302 pub peers: Vec<gossipsub::pb::PeerInfo>,
303 pub backoff: Option<u64>,
304}
305
306impl<'a> MessageRead<'a> for ControlPrune {
307 fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
308 let mut msg = Self::default();
309 while !r.is_eof() {
310 match r.next_tag(bytes) {
311 Ok(10) => msg.topic_id = Some(r.read_string(bytes)?.to_owned()),
312 Ok(18) => msg.peers.push(r.read_message::<gossipsub::pb::PeerInfo>(bytes)?),
313 Ok(24) => msg.backoff = Some(r.read_uint64(bytes)?),
314 Ok(t) => { r.read_unknown(bytes, t)?; }
315 Err(e) => return Err(e),
316 }
317 }
318 Ok(msg)
319 }
320}
321
322impl MessageWrite for ControlPrune {
323 fn get_size(&self) -> usize {
324 0
325 + self.topic_id.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
326 + self.peers.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
327 + self.backoff.as_ref().map_or(0, |m| 1 + sizeof_varint(*(m) as u64))
328 }
329
330 fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
331 if let Some(ref s) = self.topic_id { w.write_with_tag(10, |w| w.write_string(&**s))?; }
332 for s in &self.peers { w.write_with_tag(18, |w| w.write_message(s))?; }
333 if let Some(ref s) = self.backoff { w.write_with_tag(24, |w| w.write_uint64(*s))?; }
334 Ok(())
335 }
336}
337
338#[allow(clippy::derive_partial_eq_without_eq)]
339#[derive(Debug, Default, PartialEq, Clone)]
340pub struct ControlIDontWant {
341 pub message_ids: Vec<Vec<u8>>,
342}
343
344impl<'a> MessageRead<'a> for ControlIDontWant {
345 fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
346 let mut msg = Self::default();
347 while !r.is_eof() {
348 match r.next_tag(bytes) {
349 Ok(10) => msg.message_ids.push(r.read_bytes(bytes)?.to_owned()),
350 Ok(t) => { r.read_unknown(bytes, t)?; }
351 Err(e) => return Err(e),
352 }
353 }
354 Ok(msg)
355 }
356}
357
358impl MessageWrite for ControlIDontWant {
359 fn get_size(&self) -> usize {
360 0
361 + self.message_ids.iter().map(|s| 1 + sizeof_len((s).len())).sum::<usize>()
362 }
363
364 fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
365 for s in &self.message_ids { w.write_with_tag(10, |w| w.write_bytes(&**s))?; }
366 Ok(())
367 }
368}
369
370#[allow(clippy::derive_partial_eq_without_eq)]
371#[derive(Debug, Default, PartialEq, Clone)]
372pub struct PeerInfo {
373 pub peer_id: Option<Vec<u8>>,
374 pub signed_peer_record: Option<Vec<u8>>,
375}
376
377impl<'a> MessageRead<'a> for PeerInfo {
378 fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
379 let mut msg = Self::default();
380 while !r.is_eof() {
381 match r.next_tag(bytes) {
382 Ok(10) => msg.peer_id = Some(r.read_bytes(bytes)?.to_owned()),
383 Ok(18) => msg.signed_peer_record = Some(r.read_bytes(bytes)?.to_owned()),
384 Ok(t) => { r.read_unknown(bytes, t)?; }
385 Err(e) => return Err(e),
386 }
387 }
388 Ok(msg)
389 }
390}
391
392impl MessageWrite for PeerInfo {
393 fn get_size(&self) -> usize {
394 0
395 + self.peer_id.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
396 + self.signed_peer_record.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
397 }
398
399 fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
400 if let Some(ref s) = self.peer_id { w.write_with_tag(10, |w| w.write_bytes(&**s))?; }
401 if let Some(ref s) = self.signed_peer_record { w.write_with_tag(18, |w| w.write_bytes(&**s))?; }
402 Ok(())
403 }
404}
405
406#[allow(clippy::derive_partial_eq_without_eq)]
407#[derive(Debug, Default, PartialEq, Clone)]
408pub struct TopicDescriptor {
409 pub name: Option<String>,
410 pub auth: Option<gossipsub::pb::mod_TopicDescriptor::AuthOpts>,
411 pub enc: Option<gossipsub::pb::mod_TopicDescriptor::EncOpts>,
412}
413
414impl<'a> MessageRead<'a> for TopicDescriptor {
415 fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
416 let mut msg = Self::default();
417 while !r.is_eof() {
418 match r.next_tag(bytes) {
419 Ok(10) => msg.name = Some(r.read_string(bytes)?.to_owned()),
420 Ok(18) => msg.auth = Some(r.read_message::<gossipsub::pb::mod_TopicDescriptor::AuthOpts>(bytes)?),
421 Ok(26) => msg.enc = Some(r.read_message::<gossipsub::pb::mod_TopicDescriptor::EncOpts>(bytes)?),
422 Ok(t) => { r.read_unknown(bytes, t)?; }
423 Err(e) => return Err(e),
424 }
425 }
426 Ok(msg)
427 }
428}
429
430impl MessageWrite for TopicDescriptor {
431 fn get_size(&self) -> usize {
432 0
433 + self.name.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
434 + self.auth.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
435 + self.enc.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
436 }
437
438 fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
439 if let Some(ref s) = self.name { w.write_with_tag(10, |w| w.write_string(&**s))?; }
440 if let Some(ref s) = self.auth { w.write_with_tag(18, |w| w.write_message(s))?; }
441 if let Some(ref s) = self.enc { w.write_with_tag(26, |w| w.write_message(s))?; }
442 Ok(())
443 }
444}
445
446pub mod mod_TopicDescriptor {
447
448use super::*;
449
450#[allow(clippy::derive_partial_eq_without_eq)]
451#[derive(Debug, Default, PartialEq, Clone)]
452pub struct AuthOpts {
453 pub mode: Option<gossipsub::pb::mod_TopicDescriptor::mod_AuthOpts::AuthMode>,
454 pub keys: Vec<Vec<u8>>,
455}
456
457impl<'a> MessageRead<'a> for AuthOpts {
458 fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
459 let mut msg = Self::default();
460 while !r.is_eof() {
461 match r.next_tag(bytes) {
462 Ok(8) => msg.mode = Some(r.read_enum(bytes)?),
463 Ok(18) => msg.keys.push(r.read_bytes(bytes)?.to_owned()),
464 Ok(t) => { r.read_unknown(bytes, t)?; }
465 Err(e) => return Err(e),
466 }
467 }
468 Ok(msg)
469 }
470}
471
472impl MessageWrite for AuthOpts {
473 fn get_size(&self) -> usize {
474 0
475 + self.mode.as_ref().map_or(0, |m| 1 + sizeof_varint(*(m) as u64))
476 + self.keys.iter().map(|s| 1 + sizeof_len((s).len())).sum::<usize>()
477 }
478
479 fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
480 if let Some(ref s) = self.mode { w.write_with_tag(8, |w| w.write_enum(*s as i32))?; }
481 for s in &self.keys { w.write_with_tag(18, |w| w.write_bytes(&**s))?; }
482 Ok(())
483 }
484}
485
486pub mod mod_AuthOpts {
487
488
489#[derive(Debug, PartialEq, Eq, Clone, Copy)]
490pub enum AuthMode {
491 NONE = 0,
492 KEY = 1,
493 WOT = 2,
494}
495
496impl Default for AuthMode {
497 fn default() -> Self {
498 AuthMode::NONE
499 }
500}
501
502impl From<i32> for AuthMode {
503 fn from(i: i32) -> Self {
504 match i {
505 0 => AuthMode::NONE,
506 1 => AuthMode::KEY,
507 2 => AuthMode::WOT,
508 _ => Self::default(),
509 }
510 }
511}
512
513impl<'a> From<&'a str> for AuthMode {
514 fn from(s: &'a str) -> Self {
515 match s {
516 "NONE" => AuthMode::NONE,
517 "KEY" => AuthMode::KEY,
518 "WOT" => AuthMode::WOT,
519 _ => Self::default(),
520 }
521 }
522}
523
524}
525
526#[allow(clippy::derive_partial_eq_without_eq)]
527#[derive(Debug, Default, PartialEq, Clone)]
528pub struct EncOpts {
529 pub mode: Option<gossipsub::pb::mod_TopicDescriptor::mod_EncOpts::EncMode>,
530 pub key_hashes: Vec<Vec<u8>>,
531}
532
533impl<'a> MessageRead<'a> for EncOpts {
534 fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
535 let mut msg = Self::default();
536 while !r.is_eof() {
537 match r.next_tag(bytes) {
538 Ok(8) => msg.mode = Some(r.read_enum(bytes)?),
539 Ok(18) => msg.key_hashes.push(r.read_bytes(bytes)?.to_owned()),
540 Ok(t) => { r.read_unknown(bytes, t)?; }
541 Err(e) => return Err(e),
542 }
543 }
544 Ok(msg)
545 }
546}
547
548impl MessageWrite for EncOpts {
549 fn get_size(&self) -> usize {
550 0
551 + self.mode.as_ref().map_or(0, |m| 1 + sizeof_varint(*(m) as u64))
552 + self.key_hashes.iter().map(|s| 1 + sizeof_len((s).len())).sum::<usize>()
553 }
554
555 fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
556 if let Some(ref s) = self.mode { w.write_with_tag(8, |w| w.write_enum(*s as i32))?; }
557 for s in &self.key_hashes { w.write_with_tag(18, |w| w.write_bytes(&**s))?; }
558 Ok(())
559 }
560}
561
562pub mod mod_EncOpts {
563
564
565#[derive(Debug, PartialEq, Eq, Clone, Copy)]
566pub enum EncMode {
567 NONE = 0,
568 SHAREDKEY = 1,
569 WOT = 2,
570}
571
572impl Default for EncMode {
573 fn default() -> Self {
574 EncMode::NONE
575 }
576}
577
578impl From<i32> for EncMode {
579 fn from(i: i32) -> Self {
580 match i {
581 0 => EncMode::NONE,
582 1 => EncMode::SHAREDKEY,
583 2 => EncMode::WOT,
584 _ => Self::default(),
585 }
586 }
587}
588
589impl<'a> From<&'a str> for EncMode {
590 fn from(s: &'a str) -> Self {
591 match s {
592 "NONE" => EncMode::NONE,
593 "SHAREDKEY" => EncMode::SHAREDKEY,
594 "WOT" => EncMode::WOT,
595 _ => Self::default(),
596 }
597 }
598}
599
600}
601
602}
603