// 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::wildcard_imports)] 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 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(()) } 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()) } } } #[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) } } #[allow(clippy::cast_sign_loss)] impl MessageWrite for RawNebulaCertificateDetails { 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(u64::from(*(m))))?; w.write_packed_with_tag(26, &self.Subnets, |w, m| w.write_uint32(*m), &|m| sizeof_varint(u64::from(*(m))))?; 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(()) } 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(u64::from(*(s)))).sum::()) } + if self.Subnets.is_empty() { 0 } else { 1 + sizeof_len(self.Subnets.iter().map(|s| sizeof_varint(u64::from(*(s)))).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(u64::from(*(&self.IsCA))) } + if self.Issuer.is_empty() { 0 } else { 1 + sizeof_len((&self.Issuer).len()) } } }