2031 lines
56 KiB
Rust
2031 lines
56 KiB
Rust
|
|
use crate::{ProtoAccessor, ProtoBuilder, Result, RotoError};
|
||
|
|
use std::str;
|
||
|
|
|
||
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||
|
|
#[repr(i32)]
|
||
|
|
pub enum Edition {
|
||
|
|
EDITIONUNKNOWN, = 0,
|
||
|
|
EDITIONLEGACY, = 900,
|
||
|
|
EDITIONPROTO2, = 998,
|
||
|
|
EDITIONPROTO3, = 999,
|
||
|
|
EDITION2023, = 1000,
|
||
|
|
EDITION2024, = 1001,
|
||
|
|
EDITION2026, = 1002,
|
||
|
|
EDITIONUNSTABLE, = 9999,
|
||
|
|
EDITION1TESTONLY, = 1,
|
||
|
|
EDITION2TESTONLY, = 2,
|
||
|
|
EDITION99997TESTONLY, = 99997,
|
||
|
|
EDITION99998TESTONLY, = 99998,
|
||
|
|
EDITION99999TESTONLY, = 99999,
|
||
|
|
EDITIONMAX, = 2147483647,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl Edition {
|
||
|
|
pub fn from_i32(value: i32) -> Self {
|
||
|
|
match value {
|
||
|
|
0 => Edition::EDITIONUNKNOWN,
|
||
|
|
900 => Edition::EDITIONLEGACY,
|
||
|
|
998 => Edition::EDITIONPROTO2,
|
||
|
|
999 => Edition::EDITIONPROTO3,
|
||
|
|
1000 => Edition::EDITION2023,
|
||
|
|
1001 => Edition::EDITION2024,
|
||
|
|
1002 => Edition::EDITION2026,
|
||
|
|
9999 => Edition::EDITIONUNSTABLE,
|
||
|
|
1 => Edition::EDITION1TESTONLY,
|
||
|
|
2 => Edition::EDITION2TESTONLY,
|
||
|
|
99997 => Edition::EDITION99997TESTONLY,
|
||
|
|
99998 => Edition::EDITION99998TESTONLY,
|
||
|
|
99999 => Edition::EDITION99999TESTONLY,
|
||
|
|
2147483647 => Edition::EDITIONMAX,
|
||
|
|
_ => Edition::Unknown,
|
||
|
|
}
|
||
|
|
}}
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||
|
|
#[repr(i32)]
|
||
|
|
pub enum SymbolVisibility {
|
||
|
|
VISIBILITYUNSET, = 0,
|
||
|
|
VISIBILITYLOCAL, = 1,
|
||
|
|
VISIBILITYEXPORT, = 2,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl SymbolVisibility {
|
||
|
|
pub fn from_i32(value: i32) -> Self {
|
||
|
|
match value {
|
||
|
|
0 => SymbolVisibility::VISIBILITYUNSET,
|
||
|
|
1 => SymbolVisibility::VISIBILITYLOCAL,
|
||
|
|
2 => SymbolVisibility::VISIBILITYEXPORT,
|
||
|
|
_ => SymbolVisibility::Unknown,
|
||
|
|
}
|
||
|
|
}}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct FileDescriptorSet<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> FileDescriptorSet<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn file(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(1)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct FileDescriptorSetBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> FileDescriptorSetBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> FileDescriptorSetBuilder<'_> {
|
||
|
|
FileDescriptorSetBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn file(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct FileDescriptorProto<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> FileDescriptorProto<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(1)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn package(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(2)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn dependency(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(3)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn public_dependency(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(10)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn weak_dependency(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(11)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn option_dependency(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(15)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn message_type(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(4)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn enum_type(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(5)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn service(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(6)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn extension(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(7)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn options(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(8)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn source_code_info(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(9)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn syntax(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(12)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn edition(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(14)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct FileDescriptorProtoBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> FileDescriptorProtoBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> FileDescriptorProtoBuilder<'_> {
|
||
|
|
FileDescriptorProtoBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn package(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(2, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn dependency(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(3, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn public_dependency(mut self, value: i32) -> Result<Self> {
|
||
|
|
self.builder.write_int32(10, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn weak_dependency(mut self, value: i32) -> Result<Self> {
|
||
|
|
self.builder.write_int32(11, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn option_dependency(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(15, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn message_type(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(4, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn enum_type(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(5, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn service(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(6, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn extension(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(7, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn options(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(8, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn source_code_info(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(9, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn syntax(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(12, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn edition(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(14, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct DescriptorProto<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> DescriptorProto<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(1)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn field(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(2)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn extension(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(6)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn nested_type(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(3)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn enum_type(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(4)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn extension_range(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(5)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn oneof_decl(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(8)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn options(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(7)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn reserved_range(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(9)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn reserved_name(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(10)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn visibility(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(11)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct DescriptorProtoBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> DescriptorProtoBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> DescriptorProtoBuilder<'_> {
|
||
|
|
DescriptorProtoBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn field(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(2, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn extension(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(6, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn nested_type(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(3, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn enum_type(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(4, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn extension_range(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(5, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn oneof_decl(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(8, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn options(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(7, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn reserved_range(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(9, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn reserved_name(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(10, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn visibility(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(11, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct ExtensionRangeOptions<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> ExtensionRangeOptions<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(999)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn declaration(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(2)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(50)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn verification(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(3)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct ExtensionRangeOptionsBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> ExtensionRangeOptionsBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> ExtensionRangeOptionsBuilder<'_> {
|
||
|
|
ExtensionRangeOptionsBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(999, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn declaration(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(2, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(50, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn verification(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(3, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct FieldDescriptorProto<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> FieldDescriptorProto<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(1)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn number(&self) -> Result<i32> {
|
||
|
|
let (bytes, _) = self.0.get_value(3)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as i32).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn label(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(4)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn type(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(5)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn type_name(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(6)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn extendee(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(2)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn default_value(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(7)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn oneof_index(&self) -> Result<i32> {
|
||
|
|
let (bytes, _) = self.0.get_value(9)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as i32).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn json_name(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(10)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn options(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(8)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn proto3_optional(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(17)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct FieldDescriptorProtoBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> FieldDescriptorProtoBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> FieldDescriptorProtoBuilder<'_> {
|
||
|
|
FieldDescriptorProtoBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn number(mut self, value: i32) -> Result<Self> {
|
||
|
|
self.builder.write_int32(3, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn label(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(4, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn type(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(5, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn type_name(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(6, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn extendee(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(2, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn default_value(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(7, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn oneof_index(mut self, value: i32) -> Result<Self> {
|
||
|
|
self.builder.write_int32(9, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn json_name(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(10, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn options(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(8, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn proto3_optional(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(17, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct OneofDescriptorProto<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> OneofDescriptorProto<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(1)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn options(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(2)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct OneofDescriptorProtoBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> OneofDescriptorProtoBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> OneofDescriptorProtoBuilder<'_> {
|
||
|
|
OneofDescriptorProtoBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn options(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(2, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct EnumDescriptorProto<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> EnumDescriptorProto<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(1)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn value(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(2)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn options(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(3)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn reserved_range(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(4)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn reserved_name(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(5)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn visibility(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(6)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct EnumDescriptorProtoBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> EnumDescriptorProtoBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> EnumDescriptorProtoBuilder<'_> {
|
||
|
|
EnumDescriptorProtoBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn value(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(2, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn options(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(3, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn reserved_range(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(4, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn reserved_name(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(5, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn visibility(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(6, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct EnumValueDescriptorProto<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> EnumValueDescriptorProto<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(1)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn number(&self) -> Result<i32> {
|
||
|
|
let (bytes, _) = self.0.get_value(2)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as i32).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn options(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(3)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct EnumValueDescriptorProtoBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> EnumValueDescriptorProtoBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> EnumValueDescriptorProtoBuilder<'_> {
|
||
|
|
EnumValueDescriptorProtoBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn number(mut self, value: i32) -> Result<Self> {
|
||
|
|
self.builder.write_int32(2, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn options(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(3, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct ServiceDescriptorProto<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> ServiceDescriptorProto<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(1)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn method(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(2)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn options(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(3)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct ServiceDescriptorProtoBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> ServiceDescriptorProtoBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> ServiceDescriptorProtoBuilder<'_> {
|
||
|
|
ServiceDescriptorProtoBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn method(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(2, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn options(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(3, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct MethodDescriptorProto<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> MethodDescriptorProto<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(1)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn input_type(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(2)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn output_type(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(3)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn options(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(4)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn client_streaming(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(5)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn server_streaming(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(6)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct MethodDescriptorProtoBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> MethodDescriptorProtoBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> MethodDescriptorProtoBuilder<'_> {
|
||
|
|
MethodDescriptorProtoBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn input_type(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(2, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn output_type(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(3, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn options(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(4, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn client_streaming(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(5, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn server_streaming(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(6, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct FileOptions<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> FileOptions<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn java_package(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(1)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn java_outer_classname(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(8)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn java_multiple_files(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(10)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn java_generate_equals_and_hash(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(20)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn java_string_check_utf8(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(27)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn optimize_for(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(9)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn go_package(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(11)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn cc_generic_services(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(16)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn java_generic_services(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(17)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn py_generic_services(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(18)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(23)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn cc_enable_arenas(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(31)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn objc_class_prefix(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(36)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn csharp_namespace(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(37)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn swift_prefix(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(39)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn php_class_prefix(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(40)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn php_namespace(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(41)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn php_metadata_namespace(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(44)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn ruby_package(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(45)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(50)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(999)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct FileOptionsBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> FileOptionsBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> FileOptionsBuilder<'_> {
|
||
|
|
FileOptionsBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn java_package(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn java_outer_classname(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(8, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn java_multiple_files(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(10, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn java_generate_equals_and_hash(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(20, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn java_string_check_utf8(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(27, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn optimize_for(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(9, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn go_package(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(11, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn cc_generic_services(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(16, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn java_generic_services(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(17, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn py_generic_services(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(18, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(23, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn cc_enable_arenas(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(31, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn objc_class_prefix(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(36, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn csharp_namespace(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(37, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn swift_prefix(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(39, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn php_class_prefix(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(40, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn php_namespace(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(41, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn php_metadata_namespace(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(44, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn ruby_package(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(45, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(50, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(999, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct MessageOptions<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> MessageOptions<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn message_set_wire_format(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(1)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn no_standard_descriptor_accessor(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(2)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(3)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn map_entry(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(7)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated_legacy_json_field_conflicts(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(11)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(12)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(999)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct MessageOptionsBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> MessageOptionsBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> MessageOptionsBuilder<'_> {
|
||
|
|
MessageOptionsBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn message_set_wire_format(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn no_standard_descriptor_accessor(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(2, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(3, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn map_entry(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(7, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated_legacy_json_field_conflicts(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(11, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(12, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(999, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct FieldOptions<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> FieldOptions<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn ctype(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(1)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn packed(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(2)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn jstype(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(6)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn lazy(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(5)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn unverified_lazy(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(15)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(3)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn weak(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(10)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn debug_redact(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(16)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn retention(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(17)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn targets(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(19)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn edition_defaults(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(20)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(21)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn feature_support(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(22)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(999)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct FieldOptionsBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> FieldOptionsBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> FieldOptionsBuilder<'_> {
|
||
|
|
FieldOptionsBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn ctype(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn packed(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(2, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn jstype(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(6, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn lazy(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(5, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn unverified_lazy(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(15, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(3, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn weak(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(10, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn debug_redact(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(16, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn retention(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(17, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn targets(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(19, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn edition_defaults(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(20, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(21, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn feature_support(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(22, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(999, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct OneofOptions<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> OneofOptions<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(1)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(999)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct OneofOptionsBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> OneofOptionsBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> OneofOptionsBuilder<'_> {
|
||
|
|
OneofOptionsBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(999, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct EnumOptions<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> EnumOptions<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn allow_alias(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(2)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(3)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated_legacy_json_field_conflicts(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(6)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(7)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(999)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct EnumOptionsBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> EnumOptionsBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> EnumOptionsBuilder<'_> {
|
||
|
|
EnumOptionsBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn allow_alias(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(2, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(3, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated_legacy_json_field_conflicts(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(6, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(7, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(999, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct EnumValueOptions<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> EnumValueOptions<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(1)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(2)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn debug_redact(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(3)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn feature_support(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(4)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(999)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct EnumValueOptionsBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> EnumValueOptionsBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> EnumValueOptionsBuilder<'_> {
|
||
|
|
EnumValueOptionsBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(2, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn debug_redact(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(3, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn feature_support(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(4, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(999, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct ServiceOptions<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> ServiceOptions<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(34)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(33)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(999)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct ServiceOptionsBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> ServiceOptionsBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> ServiceOptionsBuilder<'_> {
|
||
|
|
ServiceOptionsBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(34, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(33, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(999, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct MethodOptions<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> MethodOptions<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated(&self) -> Result<bool> {
|
||
|
|
let (bytes, _) = self.0.get_value(33)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v != 0).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn idempotency_level(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(34)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(35)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(999)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct MethodOptionsBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> MethodOptionsBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> MethodOptionsBuilder<'_> {
|
||
|
|
MethodOptionsBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn deprecated(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(33, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn idempotency_level(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(34, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn features(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(35, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn uninterpreted_option(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(999, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct UninterpretedOption<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> UninterpretedOption<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(2)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn identifier_value(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(3)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn positive_int_value(&self) -> Result<u32> {
|
||
|
|
let (bytes, _) = self.0.get_value(4)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u32).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn negative_int_value(&self) -> Result<i32> {
|
||
|
|
let (bytes, _) = self.0.get_value(5)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as i32).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn double_value(&self) -> Result<f64> {
|
||
|
|
let (bytes, _) = self.0.get_value(6)?;
|
||
|
|
f64::from_le_bytes(bytes.try_into().map_err(|_| RotoError::WireFormatViolation)?)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn string_value(&self) -> Result<&'a [u8]> {
|
||
|
|
let (bytes, _) = self.0.get_value(7)?;
|
||
|
|
Ok(bytes)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn aggregate_value(&self) -> Result<&'a str> {
|
||
|
|
let (bytes, _) = self.0.get_value(8)?;
|
||
|
|
str::from_utf8(bytes).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct UninterpretedOptionBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> UninterpretedOptionBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> UninterpretedOptionBuilder<'_> {
|
||
|
|
UninterpretedOptionBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn name(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(2, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn identifier_value(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(3, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn positive_int_value(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(4, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn negative_int_value(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(5, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn double_value(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(6, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn string_value(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(7, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn aggregate_value(mut self, value: &str) -> Result<Self> {
|
||
|
|
self.builder.write_string(8, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct FeatureSet<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> FeatureSet<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn field_presence(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(1)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn enum_type(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(2)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn repeated_field_encoding(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(3)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn utf8_validation(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(4)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn message_encoding(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(5)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn json_format(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(6)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn enforce_naming_style(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(7)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn default_symbol_visibility(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(8)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn enforce_proto_limits(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(9)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct FeatureSetBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> FeatureSetBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> FeatureSetBuilder<'_> {
|
||
|
|
FeatureSetBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn field_presence(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn enum_type(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(2, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn repeated_field_encoding(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(3, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn utf8_validation(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(4, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn message_encoding(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(5, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn json_format(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(6, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn enforce_naming_style(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(7, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn default_symbol_visibility(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(8, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn enforce_proto_limits(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(9, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct FeatureSetDefaults<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> FeatureSetDefaults<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn defaults(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(1)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn minimum_edition(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(4)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn maximum_edition(&self) -> Result<u64> {
|
||
|
|
let (bytes, _) = self.0.get_value(5)?;
|
||
|
|
crate::read_varint(bytes).map(|(v, _)| v as u64).map_err(|_| RotoError::WireFormatViolation)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct FeatureSetDefaultsBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> FeatureSetDefaultsBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> FeatureSetDefaultsBuilder<'_> {
|
||
|
|
FeatureSetDefaultsBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn defaults(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn minimum_edition(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(4, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn maximum_edition(mut self, value: i64) -> Result<Self> {
|
||
|
|
self.builder.write_varint(5, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct SourceCodeInfo<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> SourceCodeInfo<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn location(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(1)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct SourceCodeInfoBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> SourceCodeInfoBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> SourceCodeInfoBuilder<'_> {
|
||
|
|
SourceCodeInfoBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn location(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct GeneratedCodeInfo<'a>(ProtoAccessor<'a>);
|
||
|
|
|
||
|
|
impl<'a> GeneratedCodeInfo<'a> {
|
||
|
|
pub fn new(data: &'a [u8]) -> Result<Self> {
|
||
|
|
Ok(Self(ProtoAccessor::new(data)?))
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn annotation(&self) -> crate::RepeatedFieldIterator<'a> {
|
||
|
|
self.0.iter_repeated(1)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct GeneratedCodeInfoBuilder<'b> {
|
||
|
|
builder: ProtoBuilder<'b>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<'b> GeneratedCodeInfoBuilder<'b> {
|
||
|
|
pub fn builder(buf: &mut [u8]) -> GeneratedCodeInfoBuilder<'_> {
|
||
|
|
GeneratedCodeInfoBuilder {
|
||
|
|
builder: ProtoBuilder::new(buf),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn annotation(mut self, value: &[u8]) -> Result<Self> {
|
||
|
|
self.builder.write_bytes(1, value)?;
|
||
|
|
Ok(self)
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn finish(self) -> Result<&'b mut [u8]> {
|
||
|
|
self.builder.finish()
|
||
|
|
}
|
||
|
|
}
|