Update generated protobuf code
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
// @generated by protoc-gen-roto — do not edit
|
// @generated by protoc-gen-roto — do not edit
|
||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
|
|
||||||
use roto_runtime::{
|
use roto_runtime::{ProtoAccessor, ProtoBuilder, Result, RotoError, read_varint, RepeatedFieldIterator};
|
||||||
ProtoAccessor, ProtoBuilder, RepeatedFieldIterator, Result, RotoError, read_varint,
|
|
||||||
};
|
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
use crate::google::protobuf::descriptor;
|
use crate::google::protobuf::descriptor;
|
||||||
@@ -25,18 +23,10 @@ impl<'a> Version<'a> {
|
|||||||
let mut suffix_offset = None;
|
let mut suffix_offset = None;
|
||||||
for item in accessor.fields() {
|
for item in accessor.fields() {
|
||||||
let (offset, tag, _) = item?;
|
let (offset, tag, _) = item?;
|
||||||
if tag.field_number == 1 {
|
if tag.field_number == 1 { major_offset = Some(offset); }
|
||||||
major_offset = Some(offset);
|
if tag.field_number == 2 { minor_offset = Some(offset); }
|
||||||
}
|
if tag.field_number == 3 { patch_offset = Some(offset); }
|
||||||
if tag.field_number == 2 {
|
if tag.field_number == 4 { suffix_offset = Some(offset); }
|
||||||
minor_offset = Some(offset);
|
|
||||||
}
|
|
||||||
if tag.field_number == 3 {
|
|
||||||
patch_offset = Some(offset);
|
|
||||||
}
|
|
||||||
if tag.field_number == 4 {
|
|
||||||
suffix_offset = Some(offset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
@@ -49,46 +39,57 @@ impl<'a> Version<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn major(&self) -> roto_runtime::Result<i32> {
|
pub fn major(&self) -> roto_runtime::Result<i32> {
|
||||||
let offset = self
|
let offset = self.major_offset.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
||||||
.major_offset
|
|
||||||
.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
|
||||||
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
||||||
roto_runtime::read_varint(bytes)
|
roto_runtime::read_varint(bytes).map(|(v, _)| v as i32).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
||||||
.map(|(v, _)| v as i32)
|
|
||||||
.map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn major_or_default(&self) -> roto_runtime::Result<i32> {
|
||||||
|
self.major().or(Ok(0))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn has_major(&self) -> bool { self.major_offset.is_some() }
|
||||||
|
|
||||||
pub fn minor(&self) -> roto_runtime::Result<i32> {
|
pub fn minor(&self) -> roto_runtime::Result<i32> {
|
||||||
let offset = self
|
let offset = self.minor_offset.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
||||||
.minor_offset
|
|
||||||
.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
|
||||||
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
||||||
roto_runtime::read_varint(bytes)
|
roto_runtime::read_varint(bytes).map(|(v, _)| v as i32).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
||||||
.map(|(v, _)| v as i32)
|
|
||||||
.map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn minor_or_default(&self) -> roto_runtime::Result<i32> {
|
||||||
|
self.minor().or(Ok(0))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn has_minor(&self) -> bool { self.minor_offset.is_some() }
|
||||||
|
|
||||||
pub fn patch(&self) -> roto_runtime::Result<i32> {
|
pub fn patch(&self) -> roto_runtime::Result<i32> {
|
||||||
let offset = self
|
let offset = self.patch_offset.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
||||||
.patch_offset
|
|
||||||
.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
|
||||||
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
||||||
roto_runtime::read_varint(bytes)
|
roto_runtime::read_varint(bytes).map(|(v, _)| v as i32).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
||||||
.map(|(v, _)| v as i32)
|
|
||||||
.map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn patch_or_default(&self) -> roto_runtime::Result<i32> {
|
||||||
|
self.patch().or(Ok(0))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn has_patch(&self) -> bool { self.patch_offset.is_some() }
|
||||||
|
|
||||||
pub fn suffix(&self) -> roto_runtime::Result<&'a str> {
|
pub fn suffix(&self) -> roto_runtime::Result<&'a str> {
|
||||||
let offset = self
|
let offset = self.suffix_offset.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
||||||
.suffix_offset
|
|
||||||
.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
|
||||||
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
||||||
str::from_utf8(bytes).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
str::from_utf8(bytes).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn suffix_or_default(&self) -> roto_runtime::Result<&'a str> {
|
||||||
|
self.suffix().or(Ok(""))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn has_suffix(&self) -> bool { self.suffix_offset.is_some() }
|
||||||
|
|
||||||
pub fn raw_fields(&self) -> roto_runtime::RawFieldIterator<'a> {
|
pub fn raw_fields(&self) -> roto_runtime::RawFieldIterator<'a> {
|
||||||
self.accessor.raw_fields()
|
self.accessor.raw_fields()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct VersionBuilder<'b> {
|
pub struct VersionBuilder<'b> {
|
||||||
@@ -182,40 +183,27 @@ impl<'a> CodeGeneratorRequest<'a> {
|
|||||||
for item in accessor.fields() {
|
for item in accessor.fields() {
|
||||||
let (offset, tag, _) = item?;
|
let (offset, tag, _) = item?;
|
||||||
if tag.field_number == 1 {
|
if tag.field_number == 1 {
|
||||||
if file_to_generate_start.is_none() {
|
if file_to_generate_start.is_none() { file_to_generate_start = Some(offset); }
|
||||||
file_to_generate_start = Some(offset);
|
|
||||||
}
|
|
||||||
file_to_generate_end = Some(offset);
|
file_to_generate_end = Some(offset);
|
||||||
}
|
}
|
||||||
if tag.field_number == 2 {
|
if tag.field_number == 2 { parameter_offset = Some(offset); }
|
||||||
parameter_offset = Some(offset);
|
|
||||||
}
|
|
||||||
if tag.field_number == 15 {
|
if tag.field_number == 15 {
|
||||||
if proto_file_start.is_none() {
|
if proto_file_start.is_none() { proto_file_start = Some(offset); }
|
||||||
proto_file_start = Some(offset);
|
|
||||||
}
|
|
||||||
proto_file_end = Some(offset);
|
proto_file_end = Some(offset);
|
||||||
}
|
}
|
||||||
if tag.field_number == 17 {
|
if tag.field_number == 17 {
|
||||||
if source_file_descriptors_start.is_none() {
|
if source_file_descriptors_start.is_none() { source_file_descriptors_start = Some(offset); }
|
||||||
source_file_descriptors_start = Some(offset);
|
|
||||||
}
|
|
||||||
source_file_descriptors_end = Some(offset);
|
source_file_descriptors_end = Some(offset);
|
||||||
}
|
}
|
||||||
if tag.field_number == 3 {
|
if tag.field_number == 3 { compiler_version_offset = Some(offset); }
|
||||||
compiler_version_offset = Some(offset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
accessor,
|
accessor,
|
||||||
file_to_generate_start,
|
file_to_generate_start, file_to_generate_end,
|
||||||
file_to_generate_end,
|
|
||||||
parameter_offset,
|
parameter_offset,
|
||||||
proto_file_start,
|
proto_file_start, proto_file_end,
|
||||||
proto_file_end,
|
source_file_descriptors_start, source_file_descriptors_end,
|
||||||
source_file_descriptors_start,
|
|
||||||
source_file_descriptors_end,
|
|
||||||
compiler_version_offset,
|
compiler_version_offset,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -228,13 +216,17 @@ impl<'a> CodeGeneratorRequest<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn parameter(&self) -> roto_runtime::Result<&'a str> {
|
pub fn parameter(&self) -> roto_runtime::Result<&'a str> {
|
||||||
let offset = self
|
let offset = self.parameter_offset.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
||||||
.parameter_offset
|
|
||||||
.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
|
||||||
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
||||||
str::from_utf8(bytes).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
str::from_utf8(bytes).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn parameter_or_default(&self) -> roto_runtime::Result<&'a str> {
|
||||||
|
self.parameter().or(Ok(""))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn has_parameter(&self) -> bool { self.parameter_offset.is_some() }
|
||||||
|
|
||||||
pub fn proto_file(&self) -> roto_runtime::RepeatedFieldIterator<'a> {
|
pub fn proto_file(&self) -> roto_runtime::RepeatedFieldIterator<'a> {
|
||||||
match (self.proto_file_start, self.proto_file_end) {
|
match (self.proto_file_start, self.proto_file_end) {
|
||||||
(Some(start), Some(end)) => self.accessor.iter_repeated_range(15, start, end),
|
(Some(start), Some(end)) => self.accessor.iter_repeated_range(15, start, end),
|
||||||
@@ -243,26 +235,28 @@ impl<'a> CodeGeneratorRequest<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn source_file_descriptors(&self) -> roto_runtime::RepeatedFieldIterator<'a> {
|
pub fn source_file_descriptors(&self) -> roto_runtime::RepeatedFieldIterator<'a> {
|
||||||
match (
|
match (self.source_file_descriptors_start, self.source_file_descriptors_end) {
|
||||||
self.source_file_descriptors_start,
|
|
||||||
self.source_file_descriptors_end,
|
|
||||||
) {
|
|
||||||
(Some(start), Some(end)) => self.accessor.iter_repeated_range(17, start, end),
|
(Some(start), Some(end)) => self.accessor.iter_repeated_range(17, start, end),
|
||||||
_ => self.accessor.iter_repeated(17),
|
_ => self.accessor.iter_repeated(17),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compiler_version(&self) -> roto_runtime::Result<&'a [u8]> {
|
pub fn compiler_version(&self) -> roto_runtime::Result<&'a [u8]> {
|
||||||
let offset = self
|
let offset = self.compiler_version_offset.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
||||||
.compiler_version_offset
|
|
||||||
.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
|
||||||
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
||||||
Ok(bytes)
|
Ok(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn compiler_version_or_default(&self) -> roto_runtime::Result<&'a [u8]> {
|
||||||
|
self.compiler_version().or(Ok(&[]))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn has_compiler_version(&self) -> bool { self.compiler_version_offset.is_some() }
|
||||||
|
|
||||||
pub fn raw_fields(&self) -> roto_runtime::RawFieldIterator<'a> {
|
pub fn raw_fields(&self) -> roto_runtime::RawFieldIterator<'a> {
|
||||||
self.accessor.raw_fields()
|
self.accessor.raw_fields()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CodeGeneratorRequestBuilder<'b> {
|
pub struct CodeGeneratorRequestBuilder<'b> {
|
||||||
@@ -360,22 +354,12 @@ impl<'a> CodeGeneratorResponse<'a> {
|
|||||||
let mut file_end = None;
|
let mut file_end = None;
|
||||||
for item in accessor.fields() {
|
for item in accessor.fields() {
|
||||||
let (offset, tag, _) = item?;
|
let (offset, tag, _) = item?;
|
||||||
if tag.field_number == 1 {
|
if tag.field_number == 1 { error_offset = Some(offset); }
|
||||||
error_offset = Some(offset);
|
if tag.field_number == 2 { supported_features_offset = Some(offset); }
|
||||||
}
|
if tag.field_number == 3 { minimum_edition_offset = Some(offset); }
|
||||||
if tag.field_number == 2 {
|
if tag.field_number == 4 { maximum_edition_offset = Some(offset); }
|
||||||
supported_features_offset = Some(offset);
|
|
||||||
}
|
|
||||||
if tag.field_number == 3 {
|
|
||||||
minimum_edition_offset = Some(offset);
|
|
||||||
}
|
|
||||||
if tag.field_number == 4 {
|
|
||||||
maximum_edition_offset = Some(offset);
|
|
||||||
}
|
|
||||||
if tag.field_number == 15 {
|
if tag.field_number == 15 {
|
||||||
if file_start.is_none() {
|
if file_start.is_none() { file_start = Some(offset); }
|
||||||
file_start = Some(offset);
|
|
||||||
}
|
|
||||||
file_end = Some(offset);
|
file_end = Some(offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -386,49 +370,58 @@ impl<'a> CodeGeneratorResponse<'a> {
|
|||||||
supported_features_offset,
|
supported_features_offset,
|
||||||
minimum_edition_offset,
|
minimum_edition_offset,
|
||||||
maximum_edition_offset,
|
maximum_edition_offset,
|
||||||
file_start,
|
file_start, file_end,
|
||||||
file_end,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn error(&self) -> roto_runtime::Result<&'a str> {
|
pub fn error(&self) -> roto_runtime::Result<&'a str> {
|
||||||
let offset = self
|
let offset = self.error_offset.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
||||||
.error_offset
|
|
||||||
.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
|
||||||
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
||||||
str::from_utf8(bytes).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
str::from_utf8(bytes).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn supported_features(&self) -> roto_runtime::Result<u32> {
|
pub fn error_or_default(&self) -> roto_runtime::Result<&'a str> {
|
||||||
let offset = self
|
self.error().or(Ok(""))
|
||||||
.supported_features_offset
|
|
||||||
.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
|
||||||
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
|
||||||
roto_runtime::read_varint(bytes)
|
|
||||||
.map(|(v, _)| v as u32)
|
|
||||||
.map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn has_error(&self) -> bool { self.error_offset.is_some() }
|
||||||
|
|
||||||
|
pub fn supported_features(&self) -> roto_runtime::Result<u32> {
|
||||||
|
let offset = self.supported_features_offset.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
||||||
|
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
||||||
|
roto_runtime::read_varint(bytes).map(|(v, _)| v as u32).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn supported_features_or_default(&self) -> roto_runtime::Result<u32> {
|
||||||
|
self.supported_features().or(Ok(0))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn has_supported_features(&self) -> bool { self.supported_features_offset.is_some() }
|
||||||
|
|
||||||
pub fn minimum_edition(&self) -> roto_runtime::Result<i32> {
|
pub fn minimum_edition(&self) -> roto_runtime::Result<i32> {
|
||||||
let offset = self
|
let offset = self.minimum_edition_offset.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
||||||
.minimum_edition_offset
|
|
||||||
.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
|
||||||
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
||||||
roto_runtime::read_varint(bytes)
|
roto_runtime::read_varint(bytes).map(|(v, _)| v as i32).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
||||||
.map(|(v, _)| v as i32)
|
|
||||||
.map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn maximum_edition(&self) -> roto_runtime::Result<i32> {
|
pub fn minimum_edition_or_default(&self) -> roto_runtime::Result<i32> {
|
||||||
let offset = self
|
self.minimum_edition().or(Ok(0))
|
||||||
.maximum_edition_offset
|
|
||||||
.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
|
||||||
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
|
||||||
roto_runtime::read_varint(bytes)
|
|
||||||
.map(|(v, _)| v as i32)
|
|
||||||
.map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn has_minimum_edition(&self) -> bool { self.minimum_edition_offset.is_some() }
|
||||||
|
|
||||||
|
pub fn maximum_edition(&self) -> roto_runtime::Result<i32> {
|
||||||
|
let offset = self.maximum_edition_offset.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
||||||
|
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
||||||
|
roto_runtime::read_varint(bytes).map(|(v, _)| v as i32).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn maximum_edition_or_default(&self) -> roto_runtime::Result<i32> {
|
||||||
|
self.maximum_edition().or(Ok(0))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn has_maximum_edition(&self) -> bool { self.maximum_edition_offset.is_some() }
|
||||||
|
|
||||||
pub fn file(&self) -> roto_runtime::RepeatedFieldIterator<'a> {
|
pub fn file(&self) -> roto_runtime::RepeatedFieldIterator<'a> {
|
||||||
match (self.file_start, self.file_end) {
|
match (self.file_start, self.file_end) {
|
||||||
(Some(start), Some(end)) => self.accessor.iter_repeated_range(15, start, end),
|
(Some(start), Some(end)) => self.accessor.iter_repeated_range(15, start, end),
|
||||||
@@ -439,6 +432,7 @@ impl<'a> CodeGeneratorResponse<'a> {
|
|||||||
pub fn raw_fields(&self) -> roto_runtime::RawFieldIterator<'a> {
|
pub fn raw_fields(&self) -> roto_runtime::RawFieldIterator<'a> {
|
||||||
self.accessor.raw_fields()
|
self.accessor.raw_fields()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CodeGeneratorResponseBuilder<'b> {
|
pub struct CodeGeneratorResponseBuilder<'b> {
|
||||||
@@ -552,18 +546,10 @@ pub mod code_generator_response {
|
|||||||
let mut generated_code_info_offset = None;
|
let mut generated_code_info_offset = None;
|
||||||
for item in accessor.fields() {
|
for item in accessor.fields() {
|
||||||
let (offset, tag, _) = item?;
|
let (offset, tag, _) = item?;
|
||||||
if tag.field_number == 1 {
|
if tag.field_number == 1 { name_offset = Some(offset); }
|
||||||
name_offset = Some(offset);
|
if tag.field_number == 2 { insertion_point_offset = Some(offset); }
|
||||||
}
|
if tag.field_number == 15 { content_offset = Some(offset); }
|
||||||
if tag.field_number == 2 {
|
if tag.field_number == 16 { generated_code_info_offset = Some(offset); }
|
||||||
insertion_point_offset = Some(offset);
|
|
||||||
}
|
|
||||||
if tag.field_number == 15 {
|
|
||||||
content_offset = Some(offset);
|
|
||||||
}
|
|
||||||
if tag.field_number == 16 {
|
|
||||||
generated_code_info_offset = Some(offset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
@@ -576,40 +562,57 @@ pub mod code_generator_response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn name(&self) -> roto_runtime::Result<&'a str> {
|
pub fn name(&self) -> roto_runtime::Result<&'a str> {
|
||||||
let offset = self
|
let offset = self.name_offset.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
||||||
.name_offset
|
|
||||||
.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
|
||||||
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
||||||
str::from_utf8(bytes).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
str::from_utf8(bytes).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn name_or_default(&self) -> roto_runtime::Result<&'a str> {
|
||||||
|
self.name().or(Ok(""))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn has_name(&self) -> bool { self.name_offset.is_some() }
|
||||||
|
|
||||||
pub fn insertion_point(&self) -> roto_runtime::Result<&'a str> {
|
pub fn insertion_point(&self) -> roto_runtime::Result<&'a str> {
|
||||||
let offset = self
|
let offset = self.insertion_point_offset.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
||||||
.insertion_point_offset
|
|
||||||
.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
|
||||||
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
||||||
str::from_utf8(bytes).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
str::from_utf8(bytes).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn insertion_point_or_default(&self) -> roto_runtime::Result<&'a str> {
|
||||||
|
self.insertion_point().or(Ok(""))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn has_insertion_point(&self) -> bool { self.insertion_point_offset.is_some() }
|
||||||
|
|
||||||
pub fn content(&self) -> roto_runtime::Result<&'a str> {
|
pub fn content(&self) -> roto_runtime::Result<&'a str> {
|
||||||
let offset = self
|
let offset = self.content_offset.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
||||||
.content_offset
|
|
||||||
.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
|
||||||
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
||||||
str::from_utf8(bytes).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
str::from_utf8(bytes).map_err(|_| roto_runtime::RotoError::WireFormatViolation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn content_or_default(&self) -> roto_runtime::Result<&'a str> {
|
||||||
|
self.content().or(Ok(""))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn has_content(&self) -> bool { self.content_offset.is_some() }
|
||||||
|
|
||||||
pub fn generated_code_info(&self) -> roto_runtime::Result<&'a [u8]> {
|
pub fn generated_code_info(&self) -> roto_runtime::Result<&'a [u8]> {
|
||||||
let offset = self
|
let offset = self.generated_code_info_offset.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
||||||
.generated_code_info_offset
|
|
||||||
.ok_or(roto_runtime::RotoError::FieldNotFound)?;
|
|
||||||
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
let (bytes, _) = self.accessor.get_value_at(offset)?;
|
||||||
Ok(bytes)
|
Ok(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn generated_code_info_or_default(&self) -> roto_runtime::Result<&'a [u8]> {
|
||||||
|
self.generated_code_info().or(Ok(&[]))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn has_generated_code_info(&self) -> bool { self.generated_code_info_offset.is_some() }
|
||||||
|
|
||||||
pub fn raw_fields(&self) -> roto_runtime::RawFieldIterator<'a> {
|
pub fn raw_fields(&self) -> roto_runtime::RawFieldIterator<'a> {
|
||||||
self.accessor.raw_fields()
|
self.accessor.raw_fields()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct FileBuilder<'b> {
|
pub struct FileBuilder<'b> {
|
||||||
@@ -676,4 +679,6 @@ pub mod code_generator_response {
|
|||||||
self.builder.finish()
|
self.builder.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1358
-1333
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user