#[allow(
unused,
non_snake_case,
non_camel_case_types,
clippy::all,
unreachable_pub,
reason = "generated by protoc-gen-pbrs"
)]
mod __gen {
#![allow(
unused,
non_snake_case,
non_camel_case_types,
clippy::all,
unsafe_code,
unreachable_pub,
reason = "generated by protoc-gen-pbrs"
)]
use pbrs::prelude::*;
use pbrs::UnknownFields;
use pbrs::{
Enum, Map, MapMut, MapView, ParseError, ProtoBytes, ProtoString, Repeated, RepeatedMut,
RepeatedView, SerializeError, UnknownEnumValue,
};
fn generated_pool() -> std::sync::Arc<pbrs::DescriptorPool> {
pbrs::gencode::conformance_pool()
}
#[derive(Clone, Debug)]
pub struct Duration {
seconds: i64,
nanos: i32,
unknown: UnknownFields,
cached_size: pbrs::rt::CachedSize,
}
impl PartialEq for Duration {
fn eq(&self, other: &Self) -> bool {
if self.seconds != other.seconds {
return false;
}
if self.nanos != other.nanos {
return false;
}
self.unknown == other.unknown
}
}
impl Eq for Duration {}
impl Default for Duration {
#[inline(always)]
fn default() -> Self {
unsafe { pbrs::rt::zeroed_message() }
}
}
impl Duration {
pub fn new() -> Self {
Self::default()
}
pub const EMPTY_PARSE_OK: bool = true;
pub const FULL_NAME: &'static str = "google.protobuf.Duration";
pub fn seconds(&self) -> i64 {
self.seconds
}
pub fn set_seconds(&mut self, v: i64) {
self.cached_size.dirty();
self.seconds = v;
}
pub fn nanos(&self) -> i32 {
self.nanos
}
pub fn set_nanos(&mut self, v: i32) {
self.cached_size.dirty();
self.nanos = v;
}
#[inline(always)]
fn check_required(&self) -> Result<(), ParseError> {
Ok(())
}
fn merge_bytes(&mut self, data: &[u8], depth: u32) -> Result<(), ParseError> {
if data.is_empty() {
return self.check_required();
}
let mut pos = 0;
let mut wire = None;
self.merge_inner(data, &mut wire, &mut pos, depth, true, None)
}
fn merge_bytes_dont_enforce(&mut self, data: &[u8], depth: u32) -> Result<(), ParseError> {
if data.is_empty() {
return Ok(());
}
let mut pos = 0;
let mut wire = None;
self.merge_inner(data, &mut wire, &mut pos, depth, false, None)
}
fn merge_group(
&mut self,
data: &[u8],
wire: &mut Option<pbrs::rt::Wire>,
pos: &mut usize,
num: u32,
depth: u32,
) -> Result<(), ParseError> {
self.merge_inner(data, wire, pos, depth, false, Some(num))
}
fn merge_inner(
&mut self,
data: &[u8],
wire: &mut Option<pbrs::rt::Wire>,
pos: &mut usize,
depth: u32,
enforce: bool,
until: Option<u32>,
) -> Result<(), ParseError> {
if depth > pbrs::RECURSION_LIMIT {
return Err(ParseError::new("recursion limit exceeded"));
}
let _ = enforce;
self.cached_size.dirty();
while *pos < data.len() {
let (n, w) = pbrs::rt::decode_tag(data, pos)?;
if let Some(g) = until {
if w == pbrs::rt::WIRE_EGROUP {
if n != g {
return Err(ParseError::new("mismatched end-group"));
}
return Ok(());
}
}
match n {
1 => match w {
pbrs::rt::WIRE_VARINT => {
self.seconds = pbrs::rt::decode_varint(data, pos)? as i64;
}
_ => self
.unknown
.fields
.push(pbrs::rt::capture_unknown(data, pos, n, w)?),
},
2 => match w {
pbrs::rt::WIRE_VARINT => {
self.nanos = pbrs::rt::decode_varint(data, pos)? as i32;
}
_ => self
.unknown
.fields
.push(pbrs::rt::capture_unknown(data, pos, n, w)?),
},
_ => self
.unknown
.fields
.push(pbrs::rt::capture_unknown(data, pos, n, w)?),
}
}
if until.is_some() {
return Err(ParseError::new("truncated group"));
}
if enforce {
self.check_required()?;
}
Ok(())
}
fn validate_inner(
wire: &pbrs::rt::Wire,
pos: &mut usize,
depth: u32,
) -> Result<(), ParseError> {
Self::validate_until(wire, pos, depth, None)
}
fn validate_until(
wire: &pbrs::rt::Wire,
pos: &mut usize,
depth: u32,
until: Option<u32>,
) -> Result<(), ParseError> {
if depth > pbrs::RECURSION_LIMIT {
return Err(ParseError::new("recursion limit exceeded"));
}
let data = wire.as_slice();
while *pos < data.len() {
let (n, w) = pbrs::rt::decode_tag(data, pos)?;
if let Some(g) = until {
if w == pbrs::rt::WIRE_EGROUP {
if n != g {
return Err(ParseError::new("mismatched end-group"));
}
return Ok(());
}
}
match n {
1 => match w {
pbrs::rt::WIRE_VARINT => {
let _ = pbrs::rt::decode_varint(data, pos)? as i64;
}
_ => pbrs::rt::skip_field(data, pos, w)?,
},
2 => match w {
pbrs::rt::WIRE_VARINT => {
let _ = pbrs::rt::decode_varint(data, pos)? as i32;
}
_ => pbrs::rt::skip_field(data, pos, w)?,
},
_ => pbrs::rt::skip_field(data, pos, w)?,
}
}
if until.is_some() {
return Err(ParseError::new("truncated group"));
}
Ok(())
}
fn compute_size(&self) -> u64 {
if let Some(n) = self.cached_size.get() {
return n;
}
let mut n = self.unknown.encoded_len();
if self.seconds != 0 {
n += pbrs::rt::tag_len(1, pbrs::rt::WIRE_VARINT)
+ pbrs::rt::varint_len((self.seconds) as u64);
}
if self.nanos != 0 {
n += pbrs::rt::tag_len(2, pbrs::rt::WIRE_VARINT)
+ pbrs::rt::varint_len((self.nanos) as u64);
}
self.cached_size.set(n);
n
}
fn write_to(&self, out: &mut impl pbrs::rt::WireOut) {
if self.seconds != 0 {
pbrs::rt::encode_tag(out, 1, pbrs::rt::WIRE_VARINT);
pbrs::rt::encode_varint(out, self.seconds as u64);
}
if self.nanos != 0 {
pbrs::rt::encode_tag(out, 2, pbrs::rt::WIRE_VARINT);
pbrs::rt::encode_varint(out, self.nanos as u64);
}
self.unknown.encode(out);
}
pub fn to_json(&self) -> Result<String, SerializeError> {
Ok(self.to_json_value()?.to_string())
}
pub fn from_json(json: &str) -> Result<Self, ParseError> {
Self::from_json_ignore(json, false)
}
pub fn from_json_ignore(json: &str, ignore: bool) -> Result<Self, ParseError> {
let v = pbrs::json::parse(json)?;
Self::from_json_value(&v, ignore)
}
fn to_json_value(&self) -> Result<pbrs::json::Json, SerializeError> {
pbrs::json::duration(self.seconds(), self.nanos())
}
fn from_json_value(v: &pbrs::json::Json, _ignore: bool) -> Result<Self, ParseError> {
let (seconds, nanos) = pbrs::json::as_duration(v)?;
let mut msg = Self::new();
msg.set_seconds(seconds);
msg.set_nanos(nanos);
Ok(msg)
}
pub fn to_text(&self) -> Result<String, SerializeError> {
let mut out = String::new();
self.write_text(&mut out, 0)?;
Ok(out)
}
pub fn to_text_with_unknown(&self) -> Result<String, SerializeError> {
let mut out = String::new();
self.write_text(&mut out, 0)?;
pbrs::text::write_unknown_fields(&self.unknown, &mut out, 0);
Ok(out)
}
pub fn from_text(text: &str) -> Result<Self, ParseError> {
Self::from_text_value(&pbrs::text::parse(text)?)
}
fn write_text(&self, out: &mut String, indent: usize) -> Result<(), SerializeError> {
if self.seconds() != 0 {
pbrs::text::write_named_int64(out, indent, "seconds", self.seconds());
}
if self.nanos() != 0 {
pbrs::text::write_named_int32(out, indent, "nanos", self.nanos());
}
Ok(())
}
fn from_text_value(fields: &[(String, pbrs::text::TextValue)]) -> Result<Self, ParseError> {
let mut msg = Self::new();
for (key, val) in fields {
match key.as_str() {
"seconds" => {
msg.set_seconds(val.as_i64()?);
}
"nanos" => {
msg.set_nanos(val.as_i32()?);
}
_ => return Err(ParseError::owned(format!("unknown field {key}"))),
}
}
Ok(msg)
}
}
pbrs::impl_typed_message!(Duration, DurationView, DurationMut);
}
#[allow(unused_imports, reason = "generated by protoc-gen-pbrs")]
pub use __gen::*;