// Automatically generated rust module for 'cert_codec.proto' file #![allow(non_snake_case)] #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(unused_imports)] #![allow(unknown_lints)] #![allow(clippy::all)] #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(clippy::pedantic)] use quick_protobuf::{MessageInfo, MessageRead, MessageWrite, BytesReader, Writer, WriterBackend, Result}; use quick_protobuf::sizeofs::*; use super::*; #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Debug, Default, PartialEq, Clone)] pub struct RawNebulaCertificate { pub Details: Option, pub Signature: Vec, } impl<'a> MessageRead<'a> for RawNebulaCertificate { fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { let mut msg = Self::default(); while !r.is_eof() { match r.next_tag(bytes) { Ok(10) => msg.Details = Some(r.read_message::(bytes)?), Ok(18) => msg.Signature = r.read_bytes(bytes)?.to_owned(), Ok(t) => { r.read_unknown(bytes, t)?; } Err(e) => return Err(e), } } Ok(msg) } } impl MessageWrite for RawNebulaCertificate { fn get_size(&self) -> usize { 0 + self.Details.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size())) + if self.Signature.is_empty() { 0 } else { 1 + sizeof_len((&self.Signature).len()) } } fn write_message(&self, w: &mut Writer) -> Result<()> { if let Some(ref s) = self.Details { w.write_with_tag(10, |w| w.write_message(s))?; } if !self.Signature.is_empty() { w.write_with_tag(18, |w| w.write_bytes(&**&self.Signature))?; } Ok(()) } } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Debug, Default, PartialEq, Clone)] pub struct RawNebulaCertificateDetails { pub Name: String, pub Ips: Vec, pub Subnets: Vec, pub Groups: Vec, pub NotBefore: i64, pub NotAfter: i64, pub PublicKey: Vec, pub IsCA: bool, pub Issuer: Vec, } impl<'a> MessageRead<'a> for RawNebulaCertificateDetails { fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { let mut msg = Self::default(); while !r.is_eof() { match r.next_tag(bytes) { Ok(10) => msg.Name = r.read_string(bytes)?.to_owned(), Ok(18) => msg.Ips = r.read_packed(bytes, |r, bytes| Ok(r.read_uint32(bytes)?))?, Ok(26) => msg.Subnets = r.read_packed(bytes, |r, bytes| Ok(r.read_uint32(bytes)?))?, Ok(34) => msg.Groups.push(r.read_string(bytes)?.to_owned()), Ok(40) => msg.NotBefore = r.read_int64(bytes)?, Ok(48) => msg.NotAfter = r.read_int64(bytes)?, Ok(58) => msg.PublicKey = r.read_bytes(bytes)?.to_owned(), Ok(64) => msg.IsCA = r.read_bool(bytes)?, Ok(74) => msg.Issuer = r.read_bytes(bytes)?.to_owned(), Ok(t) => { r.read_unknown(bytes, t)?; } Err(e) => return Err(e), } } Ok(msg) } } impl MessageWrite for RawNebulaCertificateDetails { fn get_size(&self) -> usize { 0 + if self.Name == String::default() { 0 } else { 1 + sizeof_len((&self.Name).len()) } + if self.Ips.is_empty() { 0 } else { 1 + sizeof_len(self.Ips.iter().map(|s| sizeof_varint(*(s) as u64)).sum::()) } + if self.Subnets.is_empty() { 0 } else { 1 + sizeof_len(self.Subnets.iter().map(|s| sizeof_varint(*(s) as u64)).sum::()) } + self.Groups.iter().map(|s| 1 + sizeof_len((s).len())).sum::() + if self.NotBefore == 0i64 { 0 } else { 1 + sizeof_varint(*(&self.NotBefore) as u64) } + if self.NotAfter == 0i64 { 0 } else { 1 + sizeof_varint(*(&self.NotAfter) as u64) } + if self.PublicKey.is_empty() { 0 } else { 1 + sizeof_len((&self.PublicKey).len()) } + if self.IsCA == false { 0 } else { 1 + sizeof_varint(*(&self.IsCA) as u64) } + if self.Issuer.is_empty() { 0 } else { 1 + sizeof_len((&self.Issuer).len()) } } fn write_message(&self, w: &mut Writer) -> Result<()> { if self.Name != String::default() { w.write_with_tag(10, |w| w.write_string(&**&self.Name))?; } w.write_packed_with_tag(18, &self.Ips, |w, m| w.write_uint32(*m), &|m| sizeof_varint(*(m) as u64))?; w.write_packed_with_tag(26, &self.Subnets, |w, m| w.write_uint32(*m), &|m| sizeof_varint(*(m) as u64))?; for s in &self.Groups { w.write_with_tag(34, |w| w.write_string(&**s))?; } if self.NotBefore != 0i64 { w.write_with_tag(40, |w| w.write_int64(*&self.NotBefore))?; } if self.NotAfter != 0i64 { w.write_with_tag(48, |w| w.write_int64(*&self.NotAfter))?; } if !self.PublicKey.is_empty() { w.write_with_tag(58, |w| w.write_bytes(&**&self.PublicKey))?; } if self.IsCA != false { w.write_with_tag(64, |w| w.write_bool(*&self.IsCA))?; } if !self.Issuer.is_empty() { w.write_with_tag(74, |w| w.write_bytes(&**&self.Issuer))?; } Ok(()) } }