quick_protobuf_codec/generated/
test.rs

1// Automatically generated rust module for 'test.proto' file
2
3#![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::*;
15
16#[allow(clippy::derive_partial_eq_without_eq)]
17#[derive(Debug, Default, PartialEq, Clone)]
18pub struct Message {
19    pub data: Vec<u8>,
20}
21
22impl<'a> MessageRead<'a> for Message {
23    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
24        let mut msg = Self::default();
25        while !r.is_eof() {
26            match r.next_tag(bytes) {
27                Ok(10) => msg.data = r.read_bytes(bytes)?.to_owned(),
28                Ok(t) => { r.read_unknown(bytes, t)?; }
29                Err(e) => return Err(e),
30            }
31        }
32        Ok(msg)
33    }
34}
35
36impl MessageWrite for Message {
37    fn get_size(&self) -> usize {
38        0
39        + if self.data.is_empty() { 0 } else { 1 + sizeof_len((&self.data).len()) }
40    }
41
42    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
43        if !self.data.is_empty() { w.write_with_tag(10, |w| w.write_bytes(&**&self.data))?; }
44        Ok(())
45    }
46}
47