libp2p_webrtc_utils/generated/webrtc/
pb.rs1#![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 Message {
19 pub flag: Option<webrtc::pb::mod_Message::Flag>,
20 pub message: Option<Vec<u8>>,
21}
22
23impl<'a> MessageRead<'a> for Message {
24 fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
25 let mut msg = Self::default();
26 while !r.is_eof() {
27 match r.next_tag(bytes) {
28 Ok(8) => msg.flag = Some(r.read_enum(bytes)?),
29 Ok(18) => msg.message = Some(r.read_bytes(bytes)?.to_owned()),
30 Ok(t) => { r.read_unknown(bytes, t)?; }
31 Err(e) => return Err(e),
32 }
33 }
34 Ok(msg)
35 }
36}
37
38impl MessageWrite for Message {
39 fn get_size(&self) -> usize {
40 0
41 + self.flag.as_ref().map_or(0, |m| 1 + sizeof_varint(*(m) as u64))
42 + self.message.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
43 }
44
45 fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
46 if let Some(ref s) = self.flag { w.write_with_tag(8, |w| w.write_enum(*s as i32))?; }
47 if let Some(ref s) = self.message { w.write_with_tag(18, |w| w.write_bytes(&**s))?; }
48 Ok(())
49 }
50}
51
52pub mod mod_Message {
53
54
55#[derive(Debug, PartialEq, Eq, Clone, Copy)]
56pub enum Flag {
57 FIN = 0,
58 STOP_SENDING = 1,
59 RESET = 2,
60}
61
62impl Default for Flag {
63 fn default() -> Self {
64 Flag::FIN
65 }
66}
67
68impl From<i32> for Flag {
69 fn from(i: i32) -> Self {
70 match i {
71 0 => Flag::FIN,
72 1 => Flag::STOP_SENDING,
73 2 => Flag::RESET,
74 _ => Self::default(),
75 }
76 }
77}
78
79impl<'a> From<&'a str> for Flag {
80 fn from(s: &'a str) -> Self {
81 match s {
82 "FIN" => Flag::FIN,
83 "STOP_SENDING" => Flag::STOP_SENDING,
84 "RESET" => Flag::RESET,
85 _ => Self::default(),
86 }
87 }
88}
89
90}
91