From 99dd662363035bdac1b73834bb22bcc91c4c0d9e Mon Sep 17 00:00:00 2001 From: Geoffry Song Date: Mon, 4 Mar 2024 01:38:22 -0800 Subject: [PATCH] Shrink codegen even more (#173) --- pb-jelly-gen/src/codegen.rs | 87 +- pb-jelly-gen/src/protos.rs | 1539 ++++------------- pb-jelly/src/helpers.rs | 41 +- .../proto_pbtest/src/bench.rs.expected | 228 +-- .../proto_pbtest/src/extensions.rs.expected | 69 +- .../proto_pbtest/src/pbtest2.rs.expected | 789 ++------- .../proto_pbtest/src/pbtest3.rs.expected | 1135 +++--------- 7 files changed, 855 insertions(+), 3033 deletions(-) diff --git a/pb-jelly-gen/src/codegen.rs b/pb-jelly-gen/src/codegen.rs index f776a47..9d5d6b1 100644 --- a/pb-jelly-gen/src/codegen.rs +++ b/pb-jelly-gen/src/codegen.rs @@ -1453,7 +1453,30 @@ impl<'a, 'ctx> CodeWriter<'a, 'ctx> { for field in &msg_type.field { let typ = ctx.rust_type(Some(msg_type), field); - if typ.oneof.is_none() + if typ.should_serialize_packed() { + block( + ctx, + format!("if !self.{}.is_empty()", escape_name(field.get_name())), + |ctx| { + ctx.write(format!("let mut {}_size = 0;", field.get_name())); + field_iter(ctx, "val", &name, msg_type, field, |ctx| { + ctx.write(format!( + "{}_size += ::pb_jelly::Message::compute_size(val);", + field.get_name() + )); + }); + ctx.write(format!( + "size += ::pb_jelly::wire_format::serialized_length({});", + field.get_number() + )); + ctx.write(format!( + "size += ::pb_jelly::varint::serialized_length({}_size as u64);", + field.get_name() + )); + ctx.write(format!("size += {}_size;", field.get_name())); + }, + ); + } else if typ.oneof.is_none() && field.get_type() != FieldDescriptorProto_Type::TYPE_MESSAGE && !(field.get_type() == FieldDescriptorProto_Type::TYPE_ENUM && enum_err_if_default_or_unknown(ctx.ctx.find(field.get_type_name()).enum_typ())) @@ -1470,37 +1493,14 @@ impl<'a, 'ctx> CodeWriter<'a, 'ctx> { wire_format=typ.wire_format(), )); } else { - ctx.write(format!("let mut {}_size = 0;", field.get_name())); field_iter(ctx, "val", &name, msg_type, field, |ctx| { - ctx.write("let l = ::pb_jelly::Message::compute_size(val);"); - if !typ.should_serialize_packed() { - ctx.write(format!( - "{}_size += ::pb_jelly::wire_format::serialized_length({});", - field.get_name(), - field.get_number() - )); - } - if typ.is_length_delimited() { - ctx.write(format!( - "{}_size += ::pb_jelly::varint::serialized_length(l as u64);", - field.get_name() - )); - } - ctx.write(format!("{}_size += l;", field.get_name())); + ctx.write(format!( + "size += ::pb_jelly::helpers::compute_size_field::<{typ}>(val, {field_number}, ::pb_jelly::wire_format::Type::{wire_format});", + typ=typ.rust_type(), + field_number=field.get_number(), + wire_format=typ.wire_format(), + )); }); - if typ.should_serialize_packed() { - block(ctx, format!("if !self.{}.is_empty()", field.get_name()), |ctx| { - ctx.write(format!( - "size += ::pb_jelly::wire_format::serialized_length({});", - field.get_number() - )); - ctx.write(format!( - "size += ::pb_jelly::varint::serialized_length({}_size as u64);", - field.get_name() - )); - }); - } - ctx.write(format!("size += {}_size;", field.get_name())); } } if preserve_unrecognized { @@ -1551,11 +1551,12 @@ impl<'a, 'ctx> CodeWriter<'a, 'ctx> { }); ctx.write(format!("::pb_jelly::wire_format::write({}, ::pb_jelly::wire_format::Type::LengthDelimited, w)?;", field.get_number())); ctx.write("::pb_jelly::varint::write(size as u64, w)?;"); + field_iter(ctx, "val", &name, msg_type, field, |ctx| { + ctx.write("::pb_jelly::Message::serialize(val, w)?;"); + }); }, ); - } - - if typ.oneof.is_none() + } else if typ.oneof.is_none() && field.get_type() != FieldDescriptorProto_Type::TYPE_MESSAGE && !(field.get_type() == FieldDescriptorProto_Type::TYPE_ENUM && enum_err_if_default_or_unknown(ctx.ctx.find(field.get_type_name()).enum_typ())) @@ -1575,18 +1576,14 @@ impl<'a, 'ctx> CodeWriter<'a, 'ctx> { ); } else { field_iter(ctx, "val", &name, msg_type, field, |ctx| { - if !typ.should_serialize_packed() { - ctx.write(format!( - "::pb_jelly::wire_format::write({}, ::pb_jelly::wire_format::Type::{}, w)?;", - field.get_number(), - typ.wire_format() - )); - } - if typ.is_length_delimited() { - ctx.write("let l = ::pb_jelly::Message::compute_size(val);"); - ctx.write("::pb_jelly::varint::write(l as u64, w)?;"); - } - ctx.write("::pb_jelly::Message::serialize(val, w)?;"); + ctx.write( + format!( + "::pb_jelly::helpers::serialize_field::(w, val, {field_number}, ::pb_jelly::wire_format::Type::{wire_format})?;", + typ=typ.rust_type(), + field_number=field.get_number(), + wire_format=typ.wire_format(), + ) + ); }); } } diff --git a/pb-jelly-gen/src/protos.rs b/pb-jelly-gen/src/protos.rs index 97d9e4b..0a13b42 100644 --- a/pb-jelly-gen/src/protos.rs +++ b/pb-jelly-gen/src/protos.rs @@ -235,55 +235,32 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut major_size = 0; if let Some(ref val) = self.major { - let l = ::pb_jelly::Message::compute_size(val); - major_size += ::pb_jelly::wire_format::serialized_length(1); - major_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::Varint); } - size += major_size; - let mut minor_size = 0; if let Some(ref val) = self.minor { - let l = ::pb_jelly::Message::compute_size(val); - minor_size += ::pb_jelly::wire_format::serialized_length(2); - minor_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::Varint); } - size += minor_size; - let mut patch_size = 0; if let Some(ref val) = self.patch { - let l = ::pb_jelly::Message::compute_size(val); - patch_size += ::pb_jelly::wire_format::serialized_length(3); - patch_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::Varint); } - size += patch_size; - let mut suffix_size = 0; if let Some(ref val) = self.suffix { - let l = ::pb_jelly::Message::compute_size(val); - suffix_size += ::pb_jelly::wire_format::serialized_length(4); - suffix_size += ::pb_jelly::varint::serialized_length(l as u64); - suffix_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 4, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += suffix_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.major { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.minor { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.patch { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.suffix { - ::pb_jelly::wire_format::write(4, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 4, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -482,64 +459,32 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut file_to_generate_size = 0; for val in &self.file_to_generate { - let l = ::pb_jelly::Message::compute_size(val); - file_to_generate_size += ::pb_jelly::wire_format::serialized_length(1); - file_to_generate_size += ::pb_jelly::varint::serialized_length(l as u64); - file_to_generate_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += file_to_generate_size; - let mut parameter_size = 0; if let Some(ref val) = self.parameter { - let l = ::pb_jelly::Message::compute_size(val); - parameter_size += ::pb_jelly::wire_format::serialized_length(2); - parameter_size += ::pb_jelly::varint::serialized_length(l as u64); - parameter_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += parameter_size; - let mut proto_file_size = 0; for val in &self.proto_file { - let l = ::pb_jelly::Message::compute_size(val); - proto_file_size += ::pb_jelly::wire_format::serialized_length(15); - proto_file_size += ::pb_jelly::varint::serialized_length(l as u64); - proto_file_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 15, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += proto_file_size; - let mut compiler_version_size = 0; if let Some(ref val) = self.compiler_version { - let l = ::pb_jelly::Message::compute_size(val); - compiler_version_size += ::pb_jelly::wire_format::serialized_length(3); - compiler_version_size += ::pb_jelly::varint::serialized_length(l as u64); - compiler_version_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += compiler_version_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { for val in &self.file_to_generate { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.parameter { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.compiler_version { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.proto_file { - ::pb_jelly::wire_format::write(15, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 15, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -703,47 +648,26 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut error_size = 0; if let Some(ref val) = self.error { - let l = ::pb_jelly::Message::compute_size(val); - error_size += ::pb_jelly::wire_format::serialized_length(1); - error_size += ::pb_jelly::varint::serialized_length(l as u64); - error_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += error_size; - let mut supported_features_size = 0; if let Some(ref val) = self.supported_features { - let l = ::pb_jelly::Message::compute_size(val); - supported_features_size += ::pb_jelly::wire_format::serialized_length(2); - supported_features_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::Varint); } - size += supported_features_size; - let mut file_size = 0; for val in &self.file { - let l = ::pb_jelly::Message::compute_size(val); - file_size += ::pb_jelly::wire_format::serialized_length(15); - file_size += ::pb_jelly::varint::serialized_length(l as u64); - file_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 15, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += file_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.error { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.supported_features { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::Varint)?; } for val in &self.file { - ::pb_jelly::wire_format::write(15, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 15, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -968,64 +892,32 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut name_size = 0; if let Some(ref val) = self.name { - let l = ::pb_jelly::Message::compute_size(val); - name_size += ::pb_jelly::wire_format::serialized_length(1); - name_size += ::pb_jelly::varint::serialized_length(l as u64); - name_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += name_size; - let mut insertion_point_size = 0; if let Some(ref val) = self.insertion_point { - let l = ::pb_jelly::Message::compute_size(val); - insertion_point_size += ::pb_jelly::wire_format::serialized_length(2); - insertion_point_size += ::pb_jelly::varint::serialized_length(l as u64); - insertion_point_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += insertion_point_size; - let mut content_size = 0; if let Some(ref val) = self.content { - let l = ::pb_jelly::Message::compute_size(val); - content_size += ::pb_jelly::wire_format::serialized_length(15); - content_size += ::pb_jelly::varint::serialized_length(l as u64); - content_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 15, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += content_size; - let mut generated_code_info_size = 0; if let Some(ref val) = self.generated_code_info { - let l = ::pb_jelly::Message::compute_size(val); - generated_code_info_size += ::pb_jelly::wire_format::serialized_length(16); - generated_code_info_size += ::pb_jelly::varint::serialized_length(l as u64); - generated_code_info_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 16, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += generated_code_info_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.name { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.insertion_point { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.content { - ::pb_jelly::wire_format::write(15, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 15, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.generated_code_info { - ::pb_jelly::wire_format::write(16, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 16, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -1886,22 +1778,14 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut file_size = 0; for val in &self.file { - let l = ::pb_jelly::Message::compute_size(val); - file_size += ::pb_jelly::wire_format::serialized_length(1); - file_size += ::pb_jelly::varint::serialized_length(l as u64); - file_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += file_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { for val in &self.file { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -2257,170 +2141,80 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut name_size = 0; if let Some(ref val) = self.name { - let l = ::pb_jelly::Message::compute_size(val); - name_size += ::pb_jelly::wire_format::serialized_length(1); - name_size += ::pb_jelly::varint::serialized_length(l as u64); - name_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += name_size; - let mut package_size = 0; if let Some(ref val) = self.package { - let l = ::pb_jelly::Message::compute_size(val); - package_size += ::pb_jelly::wire_format::serialized_length(2); - package_size += ::pb_jelly::varint::serialized_length(l as u64); - package_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += package_size; - let mut dependency_size = 0; for val in &self.dependency { - let l = ::pb_jelly::Message::compute_size(val); - dependency_size += ::pb_jelly::wire_format::serialized_length(3); - dependency_size += ::pb_jelly::varint::serialized_length(l as u64); - dependency_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 3, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += dependency_size; - let mut public_dependency_size = 0; for val in &self.public_dependency { - let l = ::pb_jelly::Message::compute_size(val); - public_dependency_size += ::pb_jelly::wire_format::serialized_length(10); - public_dependency_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 10, ::pb_jelly::wire_format::Type::Varint); } - size += public_dependency_size; - let mut weak_dependency_size = 0; for val in &self.weak_dependency { - let l = ::pb_jelly::Message::compute_size(val); - weak_dependency_size += ::pb_jelly::wire_format::serialized_length(11); - weak_dependency_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 11, ::pb_jelly::wire_format::Type::Varint); } - size += weak_dependency_size; - let mut message_type_size = 0; for val in &self.message_type { - let l = ::pb_jelly::Message::compute_size(val); - message_type_size += ::pb_jelly::wire_format::serialized_length(4); - message_type_size += ::pb_jelly::varint::serialized_length(l as u64); - message_type_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 4, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += message_type_size; - let mut enum_type_size = 0; for val in &self.enum_type { - let l = ::pb_jelly::Message::compute_size(val); - enum_type_size += ::pb_jelly::wire_format::serialized_length(5); - enum_type_size += ::pb_jelly::varint::serialized_length(l as u64); - enum_type_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 5, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += enum_type_size; - let mut service_size = 0; for val in &self.service { - let l = ::pb_jelly::Message::compute_size(val); - service_size += ::pb_jelly::wire_format::serialized_length(6); - service_size += ::pb_jelly::varint::serialized_length(l as u64); - service_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 6, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += service_size; - let mut extension_size = 0; for val in &self.extension { - let l = ::pb_jelly::Message::compute_size(val); - extension_size += ::pb_jelly::wire_format::serialized_length(7); - extension_size += ::pb_jelly::varint::serialized_length(l as u64); - extension_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 7, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += extension_size; - let mut options_size = 0; if let Some(ref val) = self.options { - let l = ::pb_jelly::Message::compute_size(val); - options_size += ::pb_jelly::wire_format::serialized_length(8); - options_size += ::pb_jelly::varint::serialized_length(l as u64); - options_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 8, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += options_size; - let mut source_code_info_size = 0; if let Some(ref val) = self.source_code_info { - let l = ::pb_jelly::Message::compute_size(val); - source_code_info_size += ::pb_jelly::wire_format::serialized_length(9); - source_code_info_size += ::pb_jelly::varint::serialized_length(l as u64); - source_code_info_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 9, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += source_code_info_size; - let mut syntax_size = 0; if let Some(ref val) = self.syntax { - let l = ::pb_jelly::Message::compute_size(val); - syntax_size += ::pb_jelly::wire_format::serialized_length(12); - syntax_size += ::pb_jelly::varint::serialized_length(l as u64); - syntax_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 12, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += syntax_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.name { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.package { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.dependency { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.message_type { - ::pb_jelly::wire_format::write(4, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 4, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.enum_type { - ::pb_jelly::wire_format::write(5, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 5, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.service { - ::pb_jelly::wire_format::write(6, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 6, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.extension { - ::pb_jelly::wire_format::write(7, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 7, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.options { - ::pb_jelly::wire_format::write(8, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 8, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.source_code_info { - ::pb_jelly::wire_format::write(9, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 9, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.public_dependency { - ::pb_jelly::wire_format::write(10, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 10, ::pb_jelly::wire_format::Type::Varint)?; } for val in &self.weak_dependency { - ::pb_jelly::wire_format::write(11, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 11, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.syntax { - ::pb_jelly::wire_format::write(12, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 12, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -2794,148 +2588,68 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut name_size = 0; if let Some(ref val) = self.name { - let l = ::pb_jelly::Message::compute_size(val); - name_size += ::pb_jelly::wire_format::serialized_length(1); - name_size += ::pb_jelly::varint::serialized_length(l as u64); - name_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += name_size; - let mut field_size = 0; for val in &self.field { - let l = ::pb_jelly::Message::compute_size(val); - field_size += ::pb_jelly::wire_format::serialized_length(2); - field_size += ::pb_jelly::varint::serialized_length(l as u64); - field_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += field_size; - let mut extension_size = 0; for val in &self.extension { - let l = ::pb_jelly::Message::compute_size(val); - extension_size += ::pb_jelly::wire_format::serialized_length(6); - extension_size += ::pb_jelly::varint::serialized_length(l as u64); - extension_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 6, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += extension_size; - let mut nested_type_size = 0; for val in &self.nested_type { - let l = ::pb_jelly::Message::compute_size(val); - nested_type_size += ::pb_jelly::wire_format::serialized_length(3); - nested_type_size += ::pb_jelly::varint::serialized_length(l as u64); - nested_type_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += nested_type_size; - let mut enum_type_size = 0; for val in &self.enum_type { - let l = ::pb_jelly::Message::compute_size(val); - enum_type_size += ::pb_jelly::wire_format::serialized_length(4); - enum_type_size += ::pb_jelly::varint::serialized_length(l as u64); - enum_type_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 4, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += enum_type_size; - let mut extension_range_size = 0; for val in &self.extension_range { - let l = ::pb_jelly::Message::compute_size(val); - extension_range_size += ::pb_jelly::wire_format::serialized_length(5); - extension_range_size += ::pb_jelly::varint::serialized_length(l as u64); - extension_range_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 5, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += extension_range_size; - let mut oneof_decl_size = 0; for val in &self.oneof_decl { - let l = ::pb_jelly::Message::compute_size(val); - oneof_decl_size += ::pb_jelly::wire_format::serialized_length(8); - oneof_decl_size += ::pb_jelly::varint::serialized_length(l as u64); - oneof_decl_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 8, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += oneof_decl_size; - let mut options_size = 0; if let Some(ref val) = self.options { - let l = ::pb_jelly::Message::compute_size(val); - options_size += ::pb_jelly::wire_format::serialized_length(7); - options_size += ::pb_jelly::varint::serialized_length(l as u64); - options_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 7, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += options_size; - let mut reserved_range_size = 0; for val in &self.reserved_range { - let l = ::pb_jelly::Message::compute_size(val); - reserved_range_size += ::pb_jelly::wire_format::serialized_length(9); - reserved_range_size += ::pb_jelly::varint::serialized_length(l as u64); - reserved_range_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 9, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += reserved_range_size; - let mut reserved_name_size = 0; for val in &self.reserved_name { - let l = ::pb_jelly::Message::compute_size(val); - reserved_name_size += ::pb_jelly::wire_format::serialized_length(10); - reserved_name_size += ::pb_jelly::varint::serialized_length(l as u64); - reserved_name_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 10, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += reserved_name_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.name { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.field { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.nested_type { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.enum_type { - ::pb_jelly::wire_format::write(4, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 4, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.extension_range { - ::pb_jelly::wire_format::write(5, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 5, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.extension { - ::pb_jelly::wire_format::write(6, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 6, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.options { - ::pb_jelly::wire_format::write(7, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 7, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.oneof_decl { - ::pb_jelly::wire_format::write(8, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 8, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.reserved_range { - ::pb_jelly::wire_format::write(9, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 9, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.reserved_name { - ::pb_jelly::wire_format::write(10, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 10, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -3129,44 +2843,26 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut start_size = 0; if let Some(ref val) = self.start { - let l = ::pb_jelly::Message::compute_size(val); - start_size += ::pb_jelly::wire_format::serialized_length(1); - start_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::Varint); } - size += start_size; - let mut end_size = 0; if let Some(ref val) = self.end { - let l = ::pb_jelly::Message::compute_size(val); - end_size += ::pb_jelly::wire_format::serialized_length(2); - end_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::Varint); } - size += end_size; - let mut options_size = 0; if let Some(ref val) = self.options { - let l = ::pb_jelly::Message::compute_size(val); - options_size += ::pb_jelly::wire_format::serialized_length(3); - options_size += ::pb_jelly::varint::serialized_length(l as u64); - options_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += options_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.start { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.end { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.options { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -3291,30 +2987,20 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut start_size = 0; if let Some(ref val) = self.start { - let l = ::pb_jelly::Message::compute_size(val); - start_size += ::pb_jelly::wire_format::serialized_length(1); - start_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::Varint); } - size += start_size; - let mut end_size = 0; if let Some(ref val) = self.end { - let l = ::pb_jelly::Message::compute_size(val); - end_size += ::pb_jelly::wire_format::serialized_length(2); - end_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::Varint); } - size += end_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.start { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.end { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::Varint)?; } Ok(()) } @@ -3413,23 +3099,15 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut uninterpreted_option_size = 0; for val in &self.uninterpreted_option { - let l = ::pb_jelly::Message::compute_size(val); - uninterpreted_option_size += ::pb_jelly::wire_format::serialized_length(999); - uninterpreted_option_size += ::pb_jelly::varint::serialized_length(l as u64); - uninterpreted_option_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 999, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += uninterpreted_option_size; size += self._extensions.compute_size(); size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { for val in &self.uninterpreted_option { - ::pb_jelly::wire_format::write(999, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 999, ::pb_jelly::wire_format::Type::LengthDelimited)?; } self._extensions.serialize(w)?; Ok(()) @@ -3784,147 +3462,74 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut name_size = 0; if let Some(ref val) = self.name { - let l = ::pb_jelly::Message::compute_size(val); - name_size += ::pb_jelly::wire_format::serialized_length(1); - name_size += ::pb_jelly::varint::serialized_length(l as u64); - name_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += name_size; - let mut number_size = 0; if let Some(ref val) = self.number { - let l = ::pb_jelly::Message::compute_size(val); - number_size += ::pb_jelly::wire_format::serialized_length(3); - number_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::Varint); } - size += number_size; - let mut label_size = 0; if let Some(ref val) = self.label { - let l = ::pb_jelly::Message::compute_size(val); - label_size += ::pb_jelly::wire_format::serialized_length(4); - label_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 4, ::pb_jelly::wire_format::Type::Varint); } - size += label_size; - let mut type_size = 0; if let Some(ref val) = self.r#type { - let l = ::pb_jelly::Message::compute_size(val); - type_size += ::pb_jelly::wire_format::serialized_length(5); - type_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 5, ::pb_jelly::wire_format::Type::Varint); } - size += type_size; - let mut type_name_size = 0; if let Some(ref val) = self.type_name { - let l = ::pb_jelly::Message::compute_size(val); - type_name_size += ::pb_jelly::wire_format::serialized_length(6); - type_name_size += ::pb_jelly::varint::serialized_length(l as u64); - type_name_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 6, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += type_name_size; - let mut extendee_size = 0; if let Some(ref val) = self.extendee { - let l = ::pb_jelly::Message::compute_size(val); - extendee_size += ::pb_jelly::wire_format::serialized_length(2); - extendee_size += ::pb_jelly::varint::serialized_length(l as u64); - extendee_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += extendee_size; - let mut default_value_size = 0; if let Some(ref val) = self.default_value { - let l = ::pb_jelly::Message::compute_size(val); - default_value_size += ::pb_jelly::wire_format::serialized_length(7); - default_value_size += ::pb_jelly::varint::serialized_length(l as u64); - default_value_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 7, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += default_value_size; - let mut oneof_index_size = 0; if let Some(ref val) = self.oneof_index { - let l = ::pb_jelly::Message::compute_size(val); - oneof_index_size += ::pb_jelly::wire_format::serialized_length(9); - oneof_index_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 9, ::pb_jelly::wire_format::Type::Varint); } - size += oneof_index_size; - let mut json_name_size = 0; if let Some(ref val) = self.json_name { - let l = ::pb_jelly::Message::compute_size(val); - json_name_size += ::pb_jelly::wire_format::serialized_length(10); - json_name_size += ::pb_jelly::varint::serialized_length(l as u64); - json_name_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 10, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += json_name_size; - let mut options_size = 0; if let Some(ref val) = self.options { - let l = ::pb_jelly::Message::compute_size(val); - options_size += ::pb_jelly::wire_format::serialized_length(8); - options_size += ::pb_jelly::varint::serialized_length(l as u64); - options_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 8, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += options_size; - let mut proto3_optional_size = 0; if let Some(ref val) = self.proto3_optional { - let l = ::pb_jelly::Message::compute_size(val); - proto3_optional_size += ::pb_jelly::wire_format::serialized_length(17); - proto3_optional_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 17, ::pb_jelly::wire_format::Type::Varint); } - size += proto3_optional_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.name { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.extendee { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.number { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.label { - ::pb_jelly::wire_format::write(4, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 4, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.r#type { - ::pb_jelly::wire_format::write(5, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 5, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.type_name { - ::pb_jelly::wire_format::write(6, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 6, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.default_value { - ::pb_jelly::wire_format::write(7, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 7, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.options { - ::pb_jelly::wire_format::write(8, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 8, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.oneof_index { - ::pb_jelly::wire_format::write(9, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 9, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.json_name { - ::pb_jelly::wire_format::write(10, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 10, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.proto3_optional { - ::pb_jelly::wire_format::write(17, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 17, ::pb_jelly::wire_format::Type::Varint)?; } Ok(()) } @@ -4107,36 +3712,20 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut name_size = 0; if let Some(ref val) = self.name { - let l = ::pb_jelly::Message::compute_size(val); - name_size += ::pb_jelly::wire_format::serialized_length(1); - name_size += ::pb_jelly::varint::serialized_length(l as u64); - name_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += name_size; - let mut options_size = 0; if let Some(ref val) = self.options { - let l = ::pb_jelly::Message::compute_size(val); - options_size += ::pb_jelly::wire_format::serialized_length(2); - options_size += ::pb_jelly::varint::serialized_length(l as u64); - options_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += options_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.name { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.options { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -4330,78 +3919,38 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut name_size = 0; if let Some(ref val) = self.name { - let l = ::pb_jelly::Message::compute_size(val); - name_size += ::pb_jelly::wire_format::serialized_length(1); - name_size += ::pb_jelly::varint::serialized_length(l as u64); - name_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += name_size; - let mut value_size = 0; for val in &self.value { - let l = ::pb_jelly::Message::compute_size(val); - value_size += ::pb_jelly::wire_format::serialized_length(2); - value_size += ::pb_jelly::varint::serialized_length(l as u64); - value_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += value_size; - let mut options_size = 0; if let Some(ref val) = self.options { - let l = ::pb_jelly::Message::compute_size(val); - options_size += ::pb_jelly::wire_format::serialized_length(3); - options_size += ::pb_jelly::varint::serialized_length(l as u64); - options_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += options_size; - let mut reserved_range_size = 0; for val in &self.reserved_range { - let l = ::pb_jelly::Message::compute_size(val); - reserved_range_size += ::pb_jelly::wire_format::serialized_length(4); - reserved_range_size += ::pb_jelly::varint::serialized_length(l as u64); - reserved_range_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 4, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += reserved_range_size; - let mut reserved_name_size = 0; for val in &self.reserved_name { - let l = ::pb_jelly::Message::compute_size(val); - reserved_name_size += ::pb_jelly::wire_format::serialized_length(5); - reserved_name_size += ::pb_jelly::varint::serialized_length(l as u64); - reserved_name_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 5, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += reserved_name_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.name { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.value { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.options { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.reserved_range { - ::pb_jelly::wire_format::write(4, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 4, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.reserved_name { - ::pb_jelly::wire_format::write(5, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 5, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -4543,30 +4092,20 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut start_size = 0; if let Some(ref val) = self.start { - let l = ::pb_jelly::Message::compute_size(val); - start_size += ::pb_jelly::wire_format::serialized_length(1); - start_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::Varint); } - size += start_size; - let mut end_size = 0; if let Some(ref val) = self.end { - let l = ::pb_jelly::Message::compute_size(val); - end_size += ::pb_jelly::wire_format::serialized_length(2); - end_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::Varint); } - size += end_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.start { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.end { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::Varint)?; } Ok(()) } @@ -4706,47 +4245,26 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut name_size = 0; if let Some(ref val) = self.name { - let l = ::pb_jelly::Message::compute_size(val); - name_size += ::pb_jelly::wire_format::serialized_length(1); - name_size += ::pb_jelly::varint::serialized_length(l as u64); - name_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += name_size; - let mut number_size = 0; if let Some(ref val) = self.number { - let l = ::pb_jelly::Message::compute_size(val); - number_size += ::pb_jelly::wire_format::serialized_length(2); - number_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::Varint); } - size += number_size; - let mut options_size = 0; if let Some(ref val) = self.options { - let l = ::pb_jelly::Message::compute_size(val); - options_size += ::pb_jelly::wire_format::serialized_length(3); - options_size += ::pb_jelly::varint::serialized_length(l as u64); - options_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += options_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.name { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.number { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.options { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -4896,50 +4414,26 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut name_size = 0; if let Some(ref val) = self.name { - let l = ::pb_jelly::Message::compute_size(val); - name_size += ::pb_jelly::wire_format::serialized_length(1); - name_size += ::pb_jelly::varint::serialized_length(l as u64); - name_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += name_size; - let mut method_size = 0; for val in &self.method { - let l = ::pb_jelly::Message::compute_size(val); - method_size += ::pb_jelly::wire_format::serialized_length(2); - method_size += ::pb_jelly::varint::serialized_length(l as u64); - method_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += method_size; - let mut options_size = 0; if let Some(ref val) = self.options { - let l = ::pb_jelly::Message::compute_size(val); - options_size += ::pb_jelly::wire_format::serialized_length(3); - options_size += ::pb_jelly::varint::serialized_length(l as u64); - options_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += options_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.name { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.method { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.options { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -5156,86 +4650,44 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut name_size = 0; if let Some(ref val) = self.name { - let l = ::pb_jelly::Message::compute_size(val); - name_size += ::pb_jelly::wire_format::serialized_length(1); - name_size += ::pb_jelly::varint::serialized_length(l as u64); - name_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += name_size; - let mut input_type_size = 0; if let Some(ref val) = self.input_type { - let l = ::pb_jelly::Message::compute_size(val); - input_type_size += ::pb_jelly::wire_format::serialized_length(2); - input_type_size += ::pb_jelly::varint::serialized_length(l as u64); - input_type_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += input_type_size; - let mut output_type_size = 0; if let Some(ref val) = self.output_type { - let l = ::pb_jelly::Message::compute_size(val); - output_type_size += ::pb_jelly::wire_format::serialized_length(3); - output_type_size += ::pb_jelly::varint::serialized_length(l as u64); - output_type_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 3, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += output_type_size; - let mut options_size = 0; if let Some(ref val) = self.options { - let l = ::pb_jelly::Message::compute_size(val); - options_size += ::pb_jelly::wire_format::serialized_length(4); - options_size += ::pb_jelly::varint::serialized_length(l as u64); - options_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 4, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += options_size; - let mut client_streaming_size = 0; if let Some(ref val) = self.client_streaming { - let l = ::pb_jelly::Message::compute_size(val); - client_streaming_size += ::pb_jelly::wire_format::serialized_length(5); - client_streaming_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 5, ::pb_jelly::wire_format::Type::Varint); } - size += client_streaming_size; - let mut server_streaming_size = 0; if let Some(ref val) = self.server_streaming { - let l = ::pb_jelly::Message::compute_size(val); - server_streaming_size += ::pb_jelly::wire_format::serialized_length(6); - server_streaming_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 6, ::pb_jelly::wire_format::Type::Varint); } - size += server_streaming_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.name { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.input_type { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.output_type { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.options { - ::pb_jelly::wire_format::write(4, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 4, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.client_streaming { - ::pb_jelly::wire_format::write(5, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 5, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.server_streaming { - ::pb_jelly::wire_format::write(6, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 6, ::pb_jelly::wire_format::Type::Varint)?; } Ok(()) } @@ -5886,273 +5338,135 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut java_package_size = 0; if let Some(ref val) = self.java_package { - let l = ::pb_jelly::Message::compute_size(val); - java_package_size += ::pb_jelly::wire_format::serialized_length(1); - java_package_size += ::pb_jelly::varint::serialized_length(l as u64); - java_package_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += java_package_size; - let mut java_outer_classname_size = 0; if let Some(ref val) = self.java_outer_classname { - let l = ::pb_jelly::Message::compute_size(val); - java_outer_classname_size += ::pb_jelly::wire_format::serialized_length(8); - java_outer_classname_size += ::pb_jelly::varint::serialized_length(l as u64); - java_outer_classname_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 8, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += java_outer_classname_size; - let mut java_multiple_files_size = 0; if let Some(ref val) = self.java_multiple_files { - let l = ::pb_jelly::Message::compute_size(val); - java_multiple_files_size += ::pb_jelly::wire_format::serialized_length(10); - java_multiple_files_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 10, ::pb_jelly::wire_format::Type::Varint); } - size += java_multiple_files_size; - let mut java_generate_equals_and_hash_size = 0; if let Some(ref val) = self.java_generate_equals_and_hash { - let l = ::pb_jelly::Message::compute_size(val); - java_generate_equals_and_hash_size += ::pb_jelly::wire_format::serialized_length(20); - java_generate_equals_and_hash_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 20, ::pb_jelly::wire_format::Type::Varint); } - size += java_generate_equals_and_hash_size; - let mut java_string_check_utf8_size = 0; if let Some(ref val) = self.java_string_check_utf8 { - let l = ::pb_jelly::Message::compute_size(val); - java_string_check_utf8_size += ::pb_jelly::wire_format::serialized_length(27); - java_string_check_utf8_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 27, ::pb_jelly::wire_format::Type::Varint); } - size += java_string_check_utf8_size; - let mut optimize_for_size = 0; if let Some(ref val) = self.optimize_for { - let l = ::pb_jelly::Message::compute_size(val); - optimize_for_size += ::pb_jelly::wire_format::serialized_length(9); - optimize_for_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 9, ::pb_jelly::wire_format::Type::Varint); } - size += optimize_for_size; - let mut go_package_size = 0; if let Some(ref val) = self.go_package { - let l = ::pb_jelly::Message::compute_size(val); - go_package_size += ::pb_jelly::wire_format::serialized_length(11); - go_package_size += ::pb_jelly::varint::serialized_length(l as u64); - go_package_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 11, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += go_package_size; - let mut cc_generic_services_size = 0; if let Some(ref val) = self.cc_generic_services { - let l = ::pb_jelly::Message::compute_size(val); - cc_generic_services_size += ::pb_jelly::wire_format::serialized_length(16); - cc_generic_services_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 16, ::pb_jelly::wire_format::Type::Varint); } - size += cc_generic_services_size; - let mut java_generic_services_size = 0; if let Some(ref val) = self.java_generic_services { - let l = ::pb_jelly::Message::compute_size(val); - java_generic_services_size += ::pb_jelly::wire_format::serialized_length(17); - java_generic_services_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 17, ::pb_jelly::wire_format::Type::Varint); } - size += java_generic_services_size; - let mut py_generic_services_size = 0; if let Some(ref val) = self.py_generic_services { - let l = ::pb_jelly::Message::compute_size(val); - py_generic_services_size += ::pb_jelly::wire_format::serialized_length(18); - py_generic_services_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 18, ::pb_jelly::wire_format::Type::Varint); } - size += py_generic_services_size; - let mut php_generic_services_size = 0; if let Some(ref val) = self.php_generic_services { - let l = ::pb_jelly::Message::compute_size(val); - php_generic_services_size += ::pb_jelly::wire_format::serialized_length(42); - php_generic_services_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 42, ::pb_jelly::wire_format::Type::Varint); } - size += php_generic_services_size; - let mut deprecated_size = 0; if let Some(ref val) = self.deprecated { - let l = ::pb_jelly::Message::compute_size(val); - deprecated_size += ::pb_jelly::wire_format::serialized_length(23); - deprecated_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 23, ::pb_jelly::wire_format::Type::Varint); } - size += deprecated_size; - let mut cc_enable_arenas_size = 0; if let Some(ref val) = self.cc_enable_arenas { - let l = ::pb_jelly::Message::compute_size(val); - cc_enable_arenas_size += ::pb_jelly::wire_format::serialized_length(31); - cc_enable_arenas_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 31, ::pb_jelly::wire_format::Type::Varint); } - size += cc_enable_arenas_size; - let mut objc_class_prefix_size = 0; if let Some(ref val) = self.objc_class_prefix { - let l = ::pb_jelly::Message::compute_size(val); - objc_class_prefix_size += ::pb_jelly::wire_format::serialized_length(36); - objc_class_prefix_size += ::pb_jelly::varint::serialized_length(l as u64); - objc_class_prefix_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 36, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += objc_class_prefix_size; - let mut csharp_namespace_size = 0; if let Some(ref val) = self.csharp_namespace { - let l = ::pb_jelly::Message::compute_size(val); - csharp_namespace_size += ::pb_jelly::wire_format::serialized_length(37); - csharp_namespace_size += ::pb_jelly::varint::serialized_length(l as u64); - csharp_namespace_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 37, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += csharp_namespace_size; - let mut swift_prefix_size = 0; if let Some(ref val) = self.swift_prefix { - let l = ::pb_jelly::Message::compute_size(val); - swift_prefix_size += ::pb_jelly::wire_format::serialized_length(39); - swift_prefix_size += ::pb_jelly::varint::serialized_length(l as u64); - swift_prefix_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 39, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += swift_prefix_size; - let mut php_class_prefix_size = 0; if let Some(ref val) = self.php_class_prefix { - let l = ::pb_jelly::Message::compute_size(val); - php_class_prefix_size += ::pb_jelly::wire_format::serialized_length(40); - php_class_prefix_size += ::pb_jelly::varint::serialized_length(l as u64); - php_class_prefix_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 40, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += php_class_prefix_size; - let mut php_namespace_size = 0; if let Some(ref val) = self.php_namespace { - let l = ::pb_jelly::Message::compute_size(val); - php_namespace_size += ::pb_jelly::wire_format::serialized_length(41); - php_namespace_size += ::pb_jelly::varint::serialized_length(l as u64); - php_namespace_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 41, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += php_namespace_size; - let mut php_metadata_namespace_size = 0; if let Some(ref val) = self.php_metadata_namespace { - let l = ::pb_jelly::Message::compute_size(val); - php_metadata_namespace_size += ::pb_jelly::wire_format::serialized_length(44); - php_metadata_namespace_size += ::pb_jelly::varint::serialized_length(l as u64); - php_metadata_namespace_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 44, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += php_metadata_namespace_size; - let mut ruby_package_size = 0; if let Some(ref val) = self.ruby_package { - let l = ::pb_jelly::Message::compute_size(val); - ruby_package_size += ::pb_jelly::wire_format::serialized_length(45); - ruby_package_size += ::pb_jelly::varint::serialized_length(l as u64); - ruby_package_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 45, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += ruby_package_size; - let mut uninterpreted_option_size = 0; for val in &self.uninterpreted_option { - let l = ::pb_jelly::Message::compute_size(val); - uninterpreted_option_size += ::pb_jelly::wire_format::serialized_length(999); - uninterpreted_option_size += ::pb_jelly::varint::serialized_length(l as u64); - uninterpreted_option_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 999, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += uninterpreted_option_size; size += self._extensions.compute_size(); size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.java_package { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.java_outer_classname { - ::pb_jelly::wire_format::write(8, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 8, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.optimize_for { - ::pb_jelly::wire_format::write(9, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 9, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.java_multiple_files { - ::pb_jelly::wire_format::write(10, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 10, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.go_package { - ::pb_jelly::wire_format::write(11, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 11, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.cc_generic_services { - ::pb_jelly::wire_format::write(16, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 16, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.java_generic_services { - ::pb_jelly::wire_format::write(17, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 17, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.py_generic_services { - ::pb_jelly::wire_format::write(18, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 18, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.java_generate_equals_and_hash { - ::pb_jelly::wire_format::write(20, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 20, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.deprecated { - ::pb_jelly::wire_format::write(23, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 23, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.java_string_check_utf8 { - ::pb_jelly::wire_format::write(27, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 27, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.cc_enable_arenas { - ::pb_jelly::wire_format::write(31, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 31, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.objc_class_prefix { - ::pb_jelly::wire_format::write(36, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 36, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.csharp_namespace { - ::pb_jelly::wire_format::write(37, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 37, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.swift_prefix { - ::pb_jelly::wire_format::write(39, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 39, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.php_class_prefix { - ::pb_jelly::wire_format::write(40, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 40, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.php_namespace { - ::pb_jelly::wire_format::write(41, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 41, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.php_generic_services { - ::pb_jelly::wire_format::write(42, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 42, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.php_metadata_namespace { - ::pb_jelly::wire_format::write(44, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 44, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.ruby_package { - ::pb_jelly::wire_format::write(45, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 45, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.uninterpreted_option { - ::pb_jelly::wire_format::write(999, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 999, ::pb_jelly::wire_format::Type::LengthDelimited)?; } self._extensions.serialize(w)?; Ok(()) @@ -6519,67 +5833,39 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut message_set_wire_format_size = 0; if let Some(ref val) = self.message_set_wire_format { - let l = ::pb_jelly::Message::compute_size(val); - message_set_wire_format_size += ::pb_jelly::wire_format::serialized_length(1); - message_set_wire_format_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::Varint); } - size += message_set_wire_format_size; - let mut no_standard_descriptor_accessor_size = 0; if let Some(ref val) = self.no_standard_descriptor_accessor { - let l = ::pb_jelly::Message::compute_size(val); - no_standard_descriptor_accessor_size += ::pb_jelly::wire_format::serialized_length(2); - no_standard_descriptor_accessor_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::Varint); } - size += no_standard_descriptor_accessor_size; - let mut deprecated_size = 0; if let Some(ref val) = self.deprecated { - let l = ::pb_jelly::Message::compute_size(val); - deprecated_size += ::pb_jelly::wire_format::serialized_length(3); - deprecated_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::Varint); } - size += deprecated_size; - let mut map_entry_size = 0; if let Some(ref val) = self.map_entry { - let l = ::pb_jelly::Message::compute_size(val); - map_entry_size += ::pb_jelly::wire_format::serialized_length(7); - map_entry_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 7, ::pb_jelly::wire_format::Type::Varint); } - size += map_entry_size; - let mut uninterpreted_option_size = 0; for val in &self.uninterpreted_option { - let l = ::pb_jelly::Message::compute_size(val); - uninterpreted_option_size += ::pb_jelly::wire_format::serialized_length(999); - uninterpreted_option_size += ::pb_jelly::varint::serialized_length(l as u64); - uninterpreted_option_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 999, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += uninterpreted_option_size; size += self._extensions.compute_size(); size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.message_set_wire_format { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.no_standard_descriptor_accessor { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.deprecated { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.map_entry { - ::pb_jelly::wire_format::write(7, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 7, ::pb_jelly::wire_format::Type::Varint)?; } for val in &self.uninterpreted_option { - ::pb_jelly::wire_format::write(999, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 999, ::pb_jelly::wire_format::Type::LengthDelimited)?; } self._extensions.serialize(w)?; Ok(()) @@ -6881,89 +6167,51 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut ctype_size = 0; if let Some(ref val) = self.ctype { - let l = ::pb_jelly::Message::compute_size(val); - ctype_size += ::pb_jelly::wire_format::serialized_length(1); - ctype_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::Varint); } - size += ctype_size; - let mut packed_size = 0; if let Some(ref val) = self.packed { - let l = ::pb_jelly::Message::compute_size(val); - packed_size += ::pb_jelly::wire_format::serialized_length(2); - packed_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::Varint); } - size += packed_size; - let mut jstype_size = 0; if let Some(ref val) = self.jstype { - let l = ::pb_jelly::Message::compute_size(val); - jstype_size += ::pb_jelly::wire_format::serialized_length(6); - jstype_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 6, ::pb_jelly::wire_format::Type::Varint); } - size += jstype_size; - let mut lazy_size = 0; if let Some(ref val) = self.lazy { - let l = ::pb_jelly::Message::compute_size(val); - lazy_size += ::pb_jelly::wire_format::serialized_length(5); - lazy_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 5, ::pb_jelly::wire_format::Type::Varint); } - size += lazy_size; - let mut deprecated_size = 0; if let Some(ref val) = self.deprecated { - let l = ::pb_jelly::Message::compute_size(val); - deprecated_size += ::pb_jelly::wire_format::serialized_length(3); - deprecated_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::Varint); } - size += deprecated_size; - let mut weak_size = 0; if let Some(ref val) = self.weak { - let l = ::pb_jelly::Message::compute_size(val); - weak_size += ::pb_jelly::wire_format::serialized_length(10); - weak_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 10, ::pb_jelly::wire_format::Type::Varint); } - size += weak_size; - let mut uninterpreted_option_size = 0; for val in &self.uninterpreted_option { - let l = ::pb_jelly::Message::compute_size(val); - uninterpreted_option_size += ::pb_jelly::wire_format::serialized_length(999); - uninterpreted_option_size += ::pb_jelly::varint::serialized_length(l as u64); - uninterpreted_option_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 999, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += uninterpreted_option_size; size += self._extensions.compute_size(); size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.ctype { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.packed { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.deprecated { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.lazy { - ::pb_jelly::wire_format::write(5, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 5, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.jstype { - ::pb_jelly::wire_format::write(6, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 6, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.weak { - ::pb_jelly::wire_format::write(10, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 10, ::pb_jelly::wire_format::Type::Varint)?; } for val in &self.uninterpreted_option { - ::pb_jelly::wire_format::write(999, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 999, ::pb_jelly::wire_format::Type::LengthDelimited)?; } self._extensions.serialize(w)?; Ok(()) @@ -7106,23 +6354,15 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut uninterpreted_option_size = 0; for val in &self.uninterpreted_option { - let l = ::pb_jelly::Message::compute_size(val); - uninterpreted_option_size += ::pb_jelly::wire_format::serialized_length(999); - uninterpreted_option_size += ::pb_jelly::varint::serialized_length(l as u64); - uninterpreted_option_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 999, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += uninterpreted_option_size; size += self._extensions.compute_size(); size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { for val in &self.uninterpreted_option { - ::pb_jelly::wire_format::write(999, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 999, ::pb_jelly::wire_format::Type::LengthDelimited)?; } self._extensions.serialize(w)?; Ok(()) @@ -7269,45 +6509,27 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut allow_alias_size = 0; if let Some(ref val) = self.allow_alias { - let l = ::pb_jelly::Message::compute_size(val); - allow_alias_size += ::pb_jelly::wire_format::serialized_length(2); - allow_alias_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::Varint); } - size += allow_alias_size; - let mut deprecated_size = 0; if let Some(ref val) = self.deprecated { - let l = ::pb_jelly::Message::compute_size(val); - deprecated_size += ::pb_jelly::wire_format::serialized_length(3); - deprecated_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::Varint); } - size += deprecated_size; - let mut uninterpreted_option_size = 0; for val in &self.uninterpreted_option { - let l = ::pb_jelly::Message::compute_size(val); - uninterpreted_option_size += ::pb_jelly::wire_format::serialized_length(999); - uninterpreted_option_size += ::pb_jelly::varint::serialized_length(l as u64); - uninterpreted_option_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 999, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += uninterpreted_option_size; size += self._extensions.compute_size(); size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.allow_alias { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.deprecated { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::Varint)?; } for val in &self.uninterpreted_option { - ::pb_jelly::wire_format::write(999, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 999, ::pb_jelly::wire_format::Type::LengthDelimited)?; } self._extensions.serialize(w)?; Ok(()) @@ -7446,34 +6668,21 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut deprecated_size = 0; if let Some(ref val) = self.deprecated { - let l = ::pb_jelly::Message::compute_size(val); - deprecated_size += ::pb_jelly::wire_format::serialized_length(1); - deprecated_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::Varint); } - size += deprecated_size; - let mut uninterpreted_option_size = 0; for val in &self.uninterpreted_option { - let l = ::pb_jelly::Message::compute_size(val); - uninterpreted_option_size += ::pb_jelly::wire_format::serialized_length(999); - uninterpreted_option_size += ::pb_jelly::varint::serialized_length(l as u64); - uninterpreted_option_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 999, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += uninterpreted_option_size; size += self._extensions.compute_size(); size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.deprecated { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::Varint)?; } for val in &self.uninterpreted_option { - ::pb_jelly::wire_format::write(999, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 999, ::pb_jelly::wire_format::Type::LengthDelimited)?; } self._extensions.serialize(w)?; Ok(()) @@ -7610,34 +6819,21 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut deprecated_size = 0; if let Some(ref val) = self.deprecated { - let l = ::pb_jelly::Message::compute_size(val); - deprecated_size += ::pb_jelly::wire_format::serialized_length(33); - deprecated_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 33, ::pb_jelly::wire_format::Type::Varint); } - size += deprecated_size; - let mut uninterpreted_option_size = 0; for val in &self.uninterpreted_option { - let l = ::pb_jelly::Message::compute_size(val); - uninterpreted_option_size += ::pb_jelly::wire_format::serialized_length(999); - uninterpreted_option_size += ::pb_jelly::varint::serialized_length(l as u64); - uninterpreted_option_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 999, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += uninterpreted_option_size; size += self._extensions.compute_size(); size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.deprecated { - ::pb_jelly::wire_format::write(33, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 33, ::pb_jelly::wire_format::Type::Varint)?; } for val in &self.uninterpreted_option { - ::pb_jelly::wire_format::write(999, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 999, ::pb_jelly::wire_format::Type::LengthDelimited)?; } self._extensions.serialize(w)?; Ok(()) @@ -7794,45 +6990,27 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut deprecated_size = 0; if let Some(ref val) = self.deprecated { - let l = ::pb_jelly::Message::compute_size(val); - deprecated_size += ::pb_jelly::wire_format::serialized_length(33); - deprecated_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 33, ::pb_jelly::wire_format::Type::Varint); } - size += deprecated_size; - let mut idempotency_level_size = 0; if let Some(ref val) = self.idempotency_level { - let l = ::pb_jelly::Message::compute_size(val); - idempotency_level_size += ::pb_jelly::wire_format::serialized_length(34); - idempotency_level_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 34, ::pb_jelly::wire_format::Type::Varint); } - size += idempotency_level_size; - let mut uninterpreted_option_size = 0; for val in &self.uninterpreted_option { - let l = ::pb_jelly::Message::compute_size(val); - uninterpreted_option_size += ::pb_jelly::wire_format::serialized_length(999); - uninterpreted_option_size += ::pb_jelly::varint::serialized_length(l as u64); - uninterpreted_option_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 999, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += uninterpreted_option_size; size += self._extensions.compute_size(); size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.deprecated { - ::pb_jelly::wire_format::write(33, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 33, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.idempotency_level { - ::pb_jelly::wire_format::write(34, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 34, ::pb_jelly::wire_format::Type::Varint)?; } for val in &self.uninterpreted_option { - ::pb_jelly::wire_format::write(999, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 999, ::pb_jelly::wire_format::Type::LengthDelimited)?; } self._extensions.serialize(w)?; Ok(()) @@ -8081,97 +7259,50 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut name_size = 0; for val in &self.name { - let l = ::pb_jelly::Message::compute_size(val); - name_size += ::pb_jelly::wire_format::serialized_length(2); - name_size += ::pb_jelly::varint::serialized_length(l as u64); - name_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += name_size; - let mut identifier_value_size = 0; if let Some(ref val) = self.identifier_value { - let l = ::pb_jelly::Message::compute_size(val); - identifier_value_size += ::pb_jelly::wire_format::serialized_length(3); - identifier_value_size += ::pb_jelly::varint::serialized_length(l as u64); - identifier_value_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 3, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += identifier_value_size; - let mut positive_int_value_size = 0; if let Some(ref val) = self.positive_int_value { - let l = ::pb_jelly::Message::compute_size(val); - positive_int_value_size += ::pb_jelly::wire_format::serialized_length(4); - positive_int_value_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 4, ::pb_jelly::wire_format::Type::Varint); } - size += positive_int_value_size; - let mut negative_int_value_size = 0; if let Some(ref val) = self.negative_int_value { - let l = ::pb_jelly::Message::compute_size(val); - negative_int_value_size += ::pb_jelly::wire_format::serialized_length(5); - negative_int_value_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 5, ::pb_jelly::wire_format::Type::Varint); } - size += negative_int_value_size; - let mut double_value_size = 0; if let Some(ref val) = self.double_value { - let l = ::pb_jelly::Message::compute_size(val); - double_value_size += ::pb_jelly::wire_format::serialized_length(6); - double_value_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 6, ::pb_jelly::wire_format::Type::Fixed64); } - size += double_value_size; - let mut string_value_size = 0; if let Some(ref val) = self.string_value { - let l = ::pb_jelly::Message::compute_size(val); - string_value_size += ::pb_jelly::wire_format::serialized_length(7); - string_value_size += ::pb_jelly::varint::serialized_length(l as u64); - string_value_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::vec::Vec>(val, 7, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += string_value_size; - let mut aggregate_value_size = 0; if let Some(ref val) = self.aggregate_value { - let l = ::pb_jelly::Message::compute_size(val); - aggregate_value_size += ::pb_jelly::wire_format::serialized_length(8); - aggregate_value_size += ::pb_jelly::varint::serialized_length(l as u64); - aggregate_value_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 8, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += aggregate_value_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { for val in &self.name { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.identifier_value { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.positive_int_value { - ::pb_jelly::wire_format::write(4, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 4, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.negative_int_value { - ::pb_jelly::wire_format::write(5, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 5, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.double_value { - ::pb_jelly::wire_format::write(6, ::pb_jelly::wire_format::Type::Fixed64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 6, ::pb_jelly::wire_format::Type::Fixed64)?; } if let Some(ref val) = self.string_value { - ::pb_jelly::wire_format::write(7, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::>(w, val, 7, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.aggregate_value { - ::pb_jelly::wire_format::write(8, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 8, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -8327,33 +7458,20 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut name_part_size = 0; if let Some(ref val) = self.name_part { - let l = ::pb_jelly::Message::compute_size(val); - name_part_size += ::pb_jelly::wire_format::serialized_length(1); - name_part_size += ::pb_jelly::varint::serialized_length(l as u64); - name_part_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += name_part_size; - let mut is_extension_size = 0; if let Some(ref val) = self.is_extension { - let l = ::pb_jelly::Message::compute_size(val); - is_extension_size += ::pb_jelly::wire_format::serialized_length(2); - is_extension_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::Varint); } - size += is_extension_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.name_part { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.is_extension { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::Varint)?; } Ok(()) } @@ -8497,22 +7615,14 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut location_size = 0; for val in &self.location { - let l = ::pb_jelly::Message::compute_size(val); - location_size += ::pb_jelly::wire_format::serialized_length(1); - location_size += ::pb_jelly::varint::serialized_length(l as u64); - location_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += location_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { for val in &self.location { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -8768,50 +7878,33 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut path_size = 0; - for val in &self.path { - let l = ::pb_jelly::Message::compute_size(val); - path_size += l; - } if !self.path.is_empty() { + let mut path_size = 0; + for val in &self.path { + path_size += ::pb_jelly::Message::compute_size(val); + } size += ::pb_jelly::wire_format::serialized_length(1); size += ::pb_jelly::varint::serialized_length(path_size as u64); - } - size += path_size; - let mut span_size = 0; - for val in &self.span { - let l = ::pb_jelly::Message::compute_size(val); - span_size += l; + size += path_size; } if !self.span.is_empty() { + let mut span_size = 0; + for val in &self.span { + span_size += ::pb_jelly::Message::compute_size(val); + } size += ::pb_jelly::wire_format::serialized_length(2); size += ::pb_jelly::varint::serialized_length(span_size as u64); + size += span_size; } - size += span_size; - let mut leading_comments_size = 0; if let Some(ref val) = self.leading_comments { - let l = ::pb_jelly::Message::compute_size(val); - leading_comments_size += ::pb_jelly::wire_format::serialized_length(3); - leading_comments_size += ::pb_jelly::varint::serialized_length(l as u64); - leading_comments_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 3, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += leading_comments_size; - let mut trailing_comments_size = 0; if let Some(ref val) = self.trailing_comments { - let l = ::pb_jelly::Message::compute_size(val); - trailing_comments_size += ::pb_jelly::wire_format::serialized_length(4); - trailing_comments_size += ::pb_jelly::varint::serialized_length(l as u64); - trailing_comments_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 4, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += trailing_comments_size; - let mut leading_detached_comments_size = 0; for val in &self.leading_detached_comments { - let l = ::pb_jelly::Message::compute_size(val); - leading_detached_comments_size += ::pb_jelly::wire_format::serialized_length(6); - leading_detached_comments_size += ::pb_jelly::varint::serialized_length(l as u64); - leading_detached_comments_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 6, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += leading_detached_comments_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { @@ -8822,9 +7915,9 @@ pub mod google { } ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; ::pb_jelly::varint::write(size as u64, w)?; - } - for val in &self.path { - ::pb_jelly::Message::serialize(val, w)?; + for val in &self.path { + ::pb_jelly::Message::serialize(val, w)?; + } } if !self.span.is_empty() { let mut size = 0; @@ -8833,27 +7926,18 @@ pub mod google { } ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; ::pb_jelly::varint::write(size as u64, w)?; - } - for val in &self.span { - ::pb_jelly::Message::serialize(val, w)?; + for val in &self.span { + ::pb_jelly::Message::serialize(val, w)?; + } } if let Some(ref val) = self.leading_comments { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.trailing_comments { - ::pb_jelly::wire_format::write(4, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 4, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.leading_detached_comments { - ::pb_jelly::wire_format::write(6, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 6, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -8973,22 +8057,14 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut annotation_size = 0; for val in &self.annotation { - let l = ::pb_jelly::Message::compute_size(val); - annotation_size += ::pb_jelly::wire_format::serialized_length(1); - annotation_size += ::pb_jelly::varint::serialized_length(l as u64); - annotation_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += annotation_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { for val in &self.annotation { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -9148,38 +8224,24 @@ pub mod google { } fn compute_size(&self) -> usize { let mut size = 0; - let mut path_size = 0; - for val in &self.path { - let l = ::pb_jelly::Message::compute_size(val); - path_size += l; - } if !self.path.is_empty() { + let mut path_size = 0; + for val in &self.path { + path_size += ::pb_jelly::Message::compute_size(val); + } size += ::pb_jelly::wire_format::serialized_length(1); size += ::pb_jelly::varint::serialized_length(path_size as u64); + size += path_size; } - size += path_size; - let mut source_file_size = 0; if let Some(ref val) = self.source_file { - let l = ::pb_jelly::Message::compute_size(val); - source_file_size += ::pb_jelly::wire_format::serialized_length(2); - source_file_size += ::pb_jelly::varint::serialized_length(l as u64); - source_file_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += source_file_size; - let mut begin_size = 0; if let Some(ref val) = self.begin { - let l = ::pb_jelly::Message::compute_size(val); - begin_size += ::pb_jelly::wire_format::serialized_length(3); - begin_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::Varint); } - size += begin_size; - let mut end_size = 0; if let Some(ref val) = self.end { - let l = ::pb_jelly::Message::compute_size(val); - end_size += ::pb_jelly::wire_format::serialized_length(4); - end_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 4, ::pb_jelly::wire_format::Type::Varint); } - size += end_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { @@ -9190,23 +8252,18 @@ pub mod google { } ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; ::pb_jelly::varint::write(size as u64, w)?; - } - for val in &self.path { - ::pb_jelly::Message::serialize(val, w)?; + for val in &self.path { + ::pb_jelly::Message::serialize(val, w)?; + } } if let Some(ref val) = self.source_file { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.begin { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.end { - ::pb_jelly::wire_format::write(4, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 4, ::pb_jelly::wire_format::Type::Varint)?; } Ok(()) } diff --git a/pb-jelly/src/helpers.rs b/pb-jelly/src/helpers.rs index 878d1e0..8221885 100644 --- a/pb-jelly/src/helpers.rs +++ b/pb-jelly/src/helpers.rs @@ -65,6 +65,20 @@ pub fn deserialize_known_length( Ok(val) } +pub fn serialize_field( + w: &mut W, + val: &T, + field_number: u32, + wire_format: wire_format::Type, +) -> io::Result<()> { + wire_format::write(field_number, wire_format, w)?; + if let wire_format::Type::LengthDelimited = wire_format { + let l = val.compute_size(); + varint::write(l as u64, w)?; + } + val.serialize(w) +} + pub fn serialize_scalar( w: &mut W, val: &T, @@ -72,25 +86,24 @@ pub fn serialize_scalar( wire_format: wire_format::Type, ) -> io::Result<()> { if *val != T::default() { - wire_format::write(field_number, wire_format, w)?; - if let wire_format::Type::LengthDelimited = wire_format { - let l = val.compute_size(); - varint::write(l as u64, w)?; - } - val.serialize(w)?; + serialize_field(w, val, field_number, wire_format)?; } Ok(()) } +pub fn compute_size_field(val: &T, field_number: u32, wire_format: wire_format::Type) -> usize { + let mut size = wire_format::serialized_length(field_number); + let l = val.compute_size(); + if let wire_format::Type::LengthDelimited = wire_format { + size += varint::serialized_length(l as u64); + } + size + l +} + pub fn compute_size_scalar(val: &T, field_number: u32, wire_format: wire_format::Type) -> usize { - let mut size = 0; if *val != T::default() { - size += wire_format::serialized_length(field_number); - let l = val.compute_size(); - if let wire_format::Type::LengthDelimited = wire_format { - size += varint::serialized_length(l as u64); - } - size += l; + compute_size_field(val, field_number, wire_format) + } else { + 0 } - size } diff --git a/pb-test/gen/pb-jelly/proto_pbtest/src/bench.rs.expected b/pb-test/gen/pb-jelly/proto_pbtest/src/bench.rs.expected index 1b006a2..108a443 100644 --- a/pb-test/gen/pb-jelly/proto_pbtest/src/bench.rs.expected +++ b/pb-test/gen/pb-jelly/proto_pbtest/src/bench.rs.expected @@ -47,14 +47,9 @@ impl ::pb_jelly::Message for BytesData { } fn compute_size(&self) -> usize { let mut size = 0; - let mut data_size = 0; if let Some(ref val) = self.data { - let l = ::pb_jelly::Message::compute_size(val); - data_size += ::pb_jelly::wire_format::serialized_length(1); - data_size += ::pb_jelly::varint::serialized_length(l as u64); - data_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::pb_jelly::Lazy<::bytes::Bytes>>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += data_size; size } fn compute_grpc_slices_size(&self) -> usize { @@ -66,10 +61,7 @@ impl ::pb_jelly::Message for BytesData { } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.data { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::>(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -159,22 +151,14 @@ impl ::pb_jelly::Message for VecData { } fn compute_size(&self) -> usize { let mut size = 0; - let mut data_size = 0; if let Some(ref val) = self.data { - let l = ::pb_jelly::Message::compute_size(val); - data_size += ::pb_jelly::wire_format::serialized_length(1); - data_size += ::pb_jelly::varint::serialized_length(l as u64); - data_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::vec::Vec>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += data_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.data { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::>(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -263,22 +247,14 @@ impl ::pb_jelly::Message for StringMessage { } fn compute_size(&self) -> usize { let mut size = 0; - let mut data_size = 0; if let Some(ref val) = self.data { - let l = ::pb_jelly::Message::compute_size(val); - data_size += ::pb_jelly::wire_format::serialized_length(1); - data_size += ::pb_jelly::varint::serialized_length(l as u64); - data_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += data_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.data { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -367,22 +343,14 @@ impl ::pb_jelly::Message for StringMessageSSO { } fn compute_size(&self) -> usize { let mut size = 0; - let mut data_size = 0; if let Some(ref val) = self.data { - let l = ::pb_jelly::Message::compute_size(val); - data_size += ::pb_jelly::wire_format::serialized_length(1); - data_size += ::pb_jelly::varint::serialized_length(l as u64); - data_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::compact_str::CompactString>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += data_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.data { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -471,22 +439,14 @@ impl ::pb_jelly::Message for Cities { } fn compute_size(&self) -> usize { let mut size = 0; - let mut cities_size = 0; for val in &self.cities { - let l = ::pb_jelly::Message::compute_size(val); - cities_size += ::pb_jelly::wire_format::serialized_length(1); - cities_size += ::pb_jelly::varint::serialized_length(l as u64); - cities_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += cities_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { for val in &self.cities { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -707,100 +667,50 @@ impl ::pb_jelly::Message for City { } fn compute_size(&self) -> usize { let mut size = 0; - let mut city_size = 0; if let Some(ref val) = self.city { - let l = ::pb_jelly::Message::compute_size(val); - city_size += ::pb_jelly::wire_format::serialized_length(1); - city_size += ::pb_jelly::varint::serialized_length(l as u64); - city_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += city_size; - let mut growth_from_2000_to_2013_size = 0; if let Some(ref val) = self.growth_from_2000_to_2013 { - let l = ::pb_jelly::Message::compute_size(val); - growth_from_2000_to_2013_size += ::pb_jelly::wire_format::serialized_length(2); - growth_from_2000_to_2013_size += ::pb_jelly::varint::serialized_length(l as u64); - growth_from_2000_to_2013_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += growth_from_2000_to_2013_size; - let mut latitude_size = 0; if let Some(ref val) = self.latitude { - let l = ::pb_jelly::Message::compute_size(val); - latitude_size += ::pb_jelly::wire_format::serialized_length(3); - latitude_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::Fixed64); } - size += latitude_size; - let mut longitude_size = 0; if let Some(ref val) = self.longitude { - let l = ::pb_jelly::Message::compute_size(val); - longitude_size += ::pb_jelly::wire_format::serialized_length(4); - longitude_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 4, ::pb_jelly::wire_format::Type::Fixed64); } - size += longitude_size; - let mut population_size = 0; if let Some(ref val) = self.population { - let l = ::pb_jelly::Message::compute_size(val); - population_size += ::pb_jelly::wire_format::serialized_length(5); - population_size += ::pb_jelly::varint::serialized_length(l as u64); - population_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 5, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += population_size; - let mut rank_size = 0; if let Some(ref val) = self.rank { - let l = ::pb_jelly::Message::compute_size(val); - rank_size += ::pb_jelly::wire_format::serialized_length(6); - rank_size += ::pb_jelly::varint::serialized_length(l as u64); - rank_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 6, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += rank_size; - let mut state_size = 0; if let Some(ref val) = self.state { - let l = ::pb_jelly::Message::compute_size(val); - state_size += ::pb_jelly::wire_format::serialized_length(7); - state_size += ::pb_jelly::varint::serialized_length(l as u64); - state_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 7, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += state_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.city { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.growth_from_2000_to_2013 { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.latitude { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::Fixed64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::Fixed64)?; } if let Some(ref val) = self.longitude { - ::pb_jelly::wire_format::write(4, ::pb_jelly::wire_format::Type::Fixed64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 4, ::pb_jelly::wire_format::Type::Fixed64)?; } if let Some(ref val) = self.population { - ::pb_jelly::wire_format::write(5, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 5, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.rank { - ::pb_jelly::wire_format::write(6, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 6, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.state { - ::pb_jelly::wire_format::write(7, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 7, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -931,22 +841,14 @@ impl ::pb_jelly::Message for CitiesSSO { } fn compute_size(&self) -> usize { let mut size = 0; - let mut cities_size = 0; for val in &self.cities { - let l = ::pb_jelly::Message::compute_size(val); - cities_size += ::pb_jelly::wire_format::serialized_length(1); - cities_size += ::pb_jelly::varint::serialized_length(l as u64); - cities_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += cities_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { for val in &self.cities { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -1167,100 +1069,50 @@ impl ::pb_jelly::Message for CitySSO { } fn compute_size(&self) -> usize { let mut size = 0; - let mut city_size = 0; if let Some(ref val) = self.city { - let l = ::pb_jelly::Message::compute_size(val); - city_size += ::pb_jelly::wire_format::serialized_length(1); - city_size += ::pb_jelly::varint::serialized_length(l as u64); - city_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::compact_str::CompactString>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += city_size; - let mut growth_from_2000_to_2013_size = 0; if let Some(ref val) = self.growth_from_2000_to_2013 { - let l = ::pb_jelly::Message::compute_size(val); - growth_from_2000_to_2013_size += ::pb_jelly::wire_format::serialized_length(2); - growth_from_2000_to_2013_size += ::pb_jelly::varint::serialized_length(l as u64); - growth_from_2000_to_2013_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::compact_str::CompactString>(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += growth_from_2000_to_2013_size; - let mut latitude_size = 0; if let Some(ref val) = self.latitude { - let l = ::pb_jelly::Message::compute_size(val); - latitude_size += ::pb_jelly::wire_format::serialized_length(3); - latitude_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::Fixed64); } - size += latitude_size; - let mut longitude_size = 0; if let Some(ref val) = self.longitude { - let l = ::pb_jelly::Message::compute_size(val); - longitude_size += ::pb_jelly::wire_format::serialized_length(4); - longitude_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 4, ::pb_jelly::wire_format::Type::Fixed64); } - size += longitude_size; - let mut population_size = 0; if let Some(ref val) = self.population { - let l = ::pb_jelly::Message::compute_size(val); - population_size += ::pb_jelly::wire_format::serialized_length(5); - population_size += ::pb_jelly::varint::serialized_length(l as u64); - population_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::compact_str::CompactString>(val, 5, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += population_size; - let mut rank_size = 0; if let Some(ref val) = self.rank { - let l = ::pb_jelly::Message::compute_size(val); - rank_size += ::pb_jelly::wire_format::serialized_length(6); - rank_size += ::pb_jelly::varint::serialized_length(l as u64); - rank_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::compact_str::CompactString>(val, 6, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += rank_size; - let mut state_size = 0; if let Some(ref val) = self.state { - let l = ::pb_jelly::Message::compute_size(val); - state_size += ::pb_jelly::wire_format::serialized_length(7); - state_size += ::pb_jelly::varint::serialized_length(l as u64); - state_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::compact_str::CompactString>(val, 7, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += state_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.city { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.growth_from_2000_to_2013 { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.latitude { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::Fixed64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::Fixed64)?; } if let Some(ref val) = self.longitude { - ::pb_jelly::wire_format::write(4, ::pb_jelly::wire_format::Type::Fixed64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 4, ::pb_jelly::wire_format::Type::Fixed64)?; } if let Some(ref val) = self.population { - ::pb_jelly::wire_format::write(5, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 5, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.rank { - ::pb_jelly::wire_format::write(6, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 6, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.state { - ::pb_jelly::wire_format::write(7, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 7, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } diff --git a/pb-test/gen/pb-jelly/proto_pbtest/src/extensions.rs.expected b/pb-test/gen/pb-jelly/proto_pbtest/src/extensions.rs.expected index 9eb2941..aeefb79 100644 --- a/pb-test/gen/pb-jelly/proto_pbtest/src/extensions.rs.expected +++ b/pb-test/gen/pb-jelly/proto_pbtest/src/extensions.rs.expected @@ -48,20 +48,15 @@ impl ::pb_jelly::Message for Msg { } fn compute_size(&self) -> usize { let mut size = 0; - let mut base_field_size = 0; if let Some(ref val) = self.base_field { - let l = ::pb_jelly::Message::compute_size(val); - base_field_size += ::pb_jelly::wire_format::serialized_length(250); - base_field_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 250, ::pb_jelly::wire_format::Type::Varint); } - size += base_field_size; size += self._extensions.compute_size(); size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.base_field { - ::pb_jelly::wire_format::write(250, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 250, ::pb_jelly::wire_format::Type::Varint)?; } self._extensions.serialize(w)?; Ok(()) @@ -265,80 +260,44 @@ impl ::pb_jelly::Message for FakeMsg { } fn compute_size(&self) -> usize { let mut size = 0; - let mut base_field_size = 0; if let Some(ref val) = self.base_field { - let l = ::pb_jelly::Message::compute_size(val); - base_field_size += ::pb_jelly::wire_format::serialized_length(250); - base_field_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 250, ::pb_jelly::wire_format::Type::Varint); } - size += base_field_size; - let mut singular_primitive_size = 0; if let Some(ref val) = self.singular_primitive { - let l = ::pb_jelly::Message::compute_size(val); - singular_primitive_size += ::pb_jelly::wire_format::serialized_length(101); - singular_primitive_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 101, ::pb_jelly::wire_format::Type::Varint); } - size += singular_primitive_size; - let mut singular_primitive_with_default_size = 0; if let Some(ref val) = self.singular_primitive_with_default { - let l = ::pb_jelly::Message::compute_size(val); - singular_primitive_with_default_size += ::pb_jelly::wire_format::serialized_length(102); - singular_primitive_with_default_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 102, ::pb_jelly::wire_format::Type::Varint); } - size += singular_primitive_with_default_size; - let mut singular_message_size = 0; if let Some(ref val) = self.singular_message { - let l = ::pb_jelly::Message::compute_size(val); - singular_message_size += ::pb_jelly::wire_format::serialized_length(301); - singular_message_size += ::pb_jelly::varint::serialized_length(l as u64); - singular_message_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 301, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += singular_message_size; - let mut repeated_primitive_size = 0; for val in &self.repeated_primitive { - let l = ::pb_jelly::Message::compute_size(val); - repeated_primitive_size += ::pb_jelly::wire_format::serialized_length(300); - repeated_primitive_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 300, ::pb_jelly::wire_format::Type::Varint); } - size += repeated_primitive_size; - let mut repeated_message_size = 0; for val in &self.repeated_message { - let l = ::pb_jelly::Message::compute_size(val); - repeated_message_size += ::pb_jelly::wire_format::serialized_length(200); - repeated_message_size += ::pb_jelly::varint::serialized_length(l as u64); - repeated_message_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 200, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += repeated_message_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.singular_primitive { - ::pb_jelly::wire_format::write(101, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 101, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.singular_primitive_with_default { - ::pb_jelly::wire_format::write(102, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 102, ::pb_jelly::wire_format::Type::Varint)?; } for val in &self.repeated_message { - ::pb_jelly::wire_format::write(200, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 200, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.base_field { - ::pb_jelly::wire_format::write(250, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 250, ::pb_jelly::wire_format::Type::Varint)?; } for val in &self.repeated_primitive { - ::pb_jelly::wire_format::write(300, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 300, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.singular_message { - ::pb_jelly::wire_format::write(301, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 301, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } diff --git a/pb-test/gen/pb-jelly/proto_pbtest/src/pbtest2.rs.expected b/pb-test/gen/pb-jelly/proto_pbtest/src/pbtest2.rs.expected index 3267545..2f7cca4 100644 --- a/pb-test/gen/pb-jelly/proto_pbtest/src/pbtest2.rs.expected +++ b/pb-test/gen/pb-jelly/proto_pbtest/src/pbtest2.rs.expected @@ -671,22 +671,14 @@ impl ::pb_jelly::Message for Version0OneOfNoneNullable { } fn compute_size(&self) -> usize { let mut size = 0; - let mut string_one_of_size = 0; if let Version0OneOfNoneNullable_TestOneof::StringOneOf(ref val) = self.test_oneof { - let l = ::pb_jelly::Message::compute_size(val); - string_one_of_size += ::pb_jelly::wire_format::serialized_length(1); - string_one_of_size += ::pb_jelly::varint::serialized_length(l as u64); - string_one_of_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += string_one_of_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Version0OneOfNoneNullable_TestOneof::StringOneOf(ref val) = self.test_oneof { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -794,36 +786,20 @@ impl ::pb_jelly::Message for Version1OneOfNoneNullable { } fn compute_size(&self) -> usize { let mut size = 0; - let mut string_one_of_size = 0; if let Version1OneOfNoneNullable_TestOneof::StringOneOf(ref val) = self.test_oneof { - let l = ::pb_jelly::Message::compute_size(val); - string_one_of_size += ::pb_jelly::wire_format::serialized_length(1); - string_one_of_size += ::pb_jelly::varint::serialized_length(l as u64); - string_one_of_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += string_one_of_size; - let mut string_two_of_size = 0; if let Version1OneOfNoneNullable_TestOneof::StringTwoOf(ref val) = self.test_oneof { - let l = ::pb_jelly::Message::compute_size(val); - string_two_of_size += ::pb_jelly::wire_format::serialized_length(2); - string_two_of_size += ::pb_jelly::varint::serialized_length(l as u64); - string_two_of_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += string_two_of_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Version1OneOfNoneNullable_TestOneof::StringOneOf(ref val) = self.test_oneof { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Version1OneOfNoneNullable_TestOneof::StringTwoOf(ref val) = self.test_oneof { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -966,47 +942,26 @@ impl ::pb_jelly::Message for Version2OneOfNoneNullable { } fn compute_size(&self) -> usize { let mut size = 0; - let mut string_one_of_size = 0; if let Version2OneOfNoneNullable_TestOneof::StringOneOf(ref val) = self.test_oneof { - let l = ::pb_jelly::Message::compute_size(val); - string_one_of_size += ::pb_jelly::wire_format::serialized_length(1); - string_one_of_size += ::pb_jelly::varint::serialized_length(l as u64); - string_one_of_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += string_one_of_size; - let mut string_two_of_size = 0; if let Version2OneOfNoneNullable_TestOneof::StringTwoOf(ref val) = self.test_oneof { - let l = ::pb_jelly::Message::compute_size(val); - string_two_of_size += ::pb_jelly::wire_format::serialized_length(2); - string_two_of_size += ::pb_jelly::varint::serialized_length(l as u64); - string_two_of_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += string_two_of_size; - let mut int_one_Of_size = 0; if let Version2OneOfNoneNullable_TestOneof::IntOneOf(ref val) = self.test_oneof { - let l = ::pb_jelly::Message::compute_size(val); - int_one_Of_size += ::pb_jelly::wire_format::serialized_length(3); - int_one_Of_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::Varint); } - size += int_one_Of_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Version2OneOfNoneNullable_TestOneof::StringOneOf(ref val) = self.test_oneof { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Version2OneOfNoneNullable_TestOneof::StringTwoOf(ref val) = self.test_oneof { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Version2OneOfNoneNullable_TestOneof::IntOneOf(ref val) = self.test_oneof { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::Varint)?; } Ok(()) } @@ -1150,19 +1105,14 @@ impl ::pb_jelly::Message for Version1Enum { } fn compute_size(&self) -> usize { let mut size = 0; - let mut enum_field_size = 0; if let Some(ref val) = self.enum_field { - let l = ::pb_jelly::Message::compute_size(val); - enum_field_size += ::pb_jelly::wire_format::serialized_length(1); - enum_field_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::Varint); } - size += enum_field_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.enum_field { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::Varint)?; } Ok(()) } @@ -1248,19 +1198,14 @@ impl ::pb_jelly::Message for Version2Enum { } fn compute_size(&self) -> usize { let mut size = 0; - let mut enum_field_size = 0; if let Some(ref val) = self.enum_field { - let l = ::pb_jelly::Message::compute_size(val); - enum_field_size += ::pb_jelly::wire_format::serialized_length(1); - enum_field_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::Varint); } - size += enum_field_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.enum_field { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::Varint)?; } Ok(()) } @@ -1344,22 +1289,14 @@ impl ::pb_jelly::Message for Version1OneOf { } fn compute_size(&self) -> usize { let mut size = 0; - let mut string_one_of_size = 0; if let Some(Version1OneOf_TestOneof::StringOneOf(ref val)) = self.test_oneof { - let l = ::pb_jelly::Message::compute_size(val); - string_one_of_size += ::pb_jelly::wire_format::serialized_length(1); - string_one_of_size += ::pb_jelly::varint::serialized_length(l as u64); - string_one_of_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += string_one_of_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(Version1OneOf_TestOneof::StringOneOf(ref val)) = self.test_oneof { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -1468,33 +1405,20 @@ impl ::pb_jelly::Message for Version2OneOf { } fn compute_size(&self) -> usize { let mut size = 0; - let mut string_one_of_size = 0; if let Some(Version2OneOf_TestOneof::StringOneOf(ref val)) = self.test_oneof { - let l = ::pb_jelly::Message::compute_size(val); - string_one_of_size += ::pb_jelly::wire_format::serialized_length(1); - string_one_of_size += ::pb_jelly::varint::serialized_length(l as u64); - string_one_of_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += string_one_of_size; - let mut int_one_of_size = 0; if let Some(Version2OneOf_TestOneof::IntOneOf(ref val)) = self.test_oneof { - let l = ::pb_jelly::Message::compute_size(val); - int_one_of_size += ::pb_jelly::wire_format::serialized_length(2); - int_one_of_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::Varint); } - size += int_one_of_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(Version2OneOf_TestOneof::StringOneOf(ref val)) = self.test_oneof { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(Version2OneOf_TestOneof::IntOneOf(ref val)) = self.test_oneof { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::Varint)?; } Ok(()) } @@ -1617,22 +1541,14 @@ impl ::pb_jelly::Message for Version1 { } fn compute_size(&self) -> usize { let mut size = 0; - let mut required_string_size = 0; if let Some(ref val) = self.required_string { - let l = ::pb_jelly::Message::compute_size(val); - required_string_size += ::pb_jelly::wire_format::serialized_length(1); - required_string_size += ::pb_jelly::varint::serialized_length(l as u64); - required_string_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += required_string_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.required_string { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -1987,171 +1903,92 @@ impl ::pb_jelly::Message for Version2 { } fn compute_size(&self) -> usize { let mut size = 0; - let mut required_string_size = 0; if let Some(ref val) = self.required_string { - let l = ::pb_jelly::Message::compute_size(val); - required_string_size += ::pb_jelly::wire_format::serialized_length(1); - required_string_size += ::pb_jelly::varint::serialized_length(l as u64); - required_string_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += required_string_size; - let mut optional_int32_size = 0; if let Some(ref val) = self.optional_int32 { - let l = ::pb_jelly::Message::compute_size(val); - optional_int32_size += ::pb_jelly::wire_format::serialized_length(2); - optional_int32_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::Varint); } - size += optional_int32_size; - let mut optional_int64_size = 0; if let Some(ref val) = self.optional_int64 { - let l = ::pb_jelly::Message::compute_size(val); - optional_int64_size += ::pb_jelly::wire_format::serialized_length(3); - optional_int64_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::Varint); } - size += optional_int64_size; - let mut optional_uint32_size = 0; if let Some(ref val) = self.optional_uint32 { - let l = ::pb_jelly::Message::compute_size(val); - optional_uint32_size += ::pb_jelly::wire_format::serialized_length(4); - optional_uint32_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 4, ::pb_jelly::wire_format::Type::Varint); } - size += optional_uint32_size; - let mut optional_uint64_size = 0; if let Some(ref val) = self.optional_uint64 { - let l = ::pb_jelly::Message::compute_size(val); - optional_uint64_size += ::pb_jelly::wire_format::serialized_length(5); - optional_uint64_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 5, ::pb_jelly::wire_format::Type::Varint); } - size += optional_uint64_size; - let mut optional_fixed64_size = 0; if let Some(ref val) = self.optional_fixed64 { - let l = ::pb_jelly::Message::compute_size(val); - optional_fixed64_size += ::pb_jelly::wire_format::serialized_length(6); - optional_fixed64_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::pb_jelly::Fixed64>(val, 6, ::pb_jelly::wire_format::Type::Fixed64); } - size += optional_fixed64_size; - let mut optional_fixed32_size = 0; if let Some(ref val) = self.optional_fixed32 { - let l = ::pb_jelly::Message::compute_size(val); - optional_fixed32_size += ::pb_jelly::wire_format::serialized_length(7); - optional_fixed32_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::pb_jelly::Fixed32>(val, 7, ::pb_jelly::wire_format::Type::Fixed32); } - size += optional_fixed32_size; - let mut optional_sfixed64_size = 0; if let Some(ref val) = self.optional_sfixed64 { - let l = ::pb_jelly::Message::compute_size(val); - optional_sfixed64_size += ::pb_jelly::wire_format::serialized_length(8); - optional_sfixed64_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::pb_jelly::Sfixed64>(val, 8, ::pb_jelly::wire_format::Type::Fixed64); } - size += optional_sfixed64_size; - let mut optional_sfixed32_size = 0; if let Some(ref val) = self.optional_sfixed32 { - let l = ::pb_jelly::Message::compute_size(val); - optional_sfixed32_size += ::pb_jelly::wire_format::serialized_length(9); - optional_sfixed32_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::pb_jelly::Sfixed32>(val, 9, ::pb_jelly::wire_format::Type::Fixed32); } - size += optional_sfixed32_size; - let mut optional_double_size = 0; if let Some(ref val) = self.optional_double { - let l = ::pb_jelly::Message::compute_size(val); - optional_double_size += ::pb_jelly::wire_format::serialized_length(10); - optional_double_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 10, ::pb_jelly::wire_format::Type::Fixed64); } - size += optional_double_size; - let mut optional_bool_size = 0; if let Some(ref val) = self.optional_bool { - let l = ::pb_jelly::Message::compute_size(val); - optional_bool_size += ::pb_jelly::wire_format::serialized_length(11); - optional_bool_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 11, ::pb_jelly::wire_format::Type::Varint); } - size += optional_bool_size; - let mut optional_string_size = 0; if let Some(ref val) = self.optional_string { - let l = ::pb_jelly::Message::compute_size(val); - optional_string_size += ::pb_jelly::wire_format::serialized_length(12); - optional_string_size += ::pb_jelly::varint::serialized_length(l as u64); - optional_string_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 12, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += optional_string_size; - let mut optional_bytes_size = 0; if let Some(ref val) = self.optional_bytes { - let l = ::pb_jelly::Message::compute_size(val); - optional_bytes_size += ::pb_jelly::wire_format::serialized_length(13); - optional_bytes_size += ::pb_jelly::varint::serialized_length(l as u64); - optional_bytes_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::vec::Vec>(val, 13, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += optional_bytes_size; - let mut optional_float_size = 0; if let Some(ref val) = self.optional_float { - let l = ::pb_jelly::Message::compute_size(val); - optional_float_size += ::pb_jelly::wire_format::serialized_length(14); - optional_float_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 14, ::pb_jelly::wire_format::Type::Fixed32); } - size += optional_float_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.required_string { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.optional_int32 { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.optional_int64 { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.optional_uint32 { - ::pb_jelly::wire_format::write(4, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 4, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.optional_uint64 { - ::pb_jelly::wire_format::write(5, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 5, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.optional_fixed64 { - ::pb_jelly::wire_format::write(6, ::pb_jelly::wire_format::Type::Fixed64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 6, ::pb_jelly::wire_format::Type::Fixed64)?; } if let Some(ref val) = self.optional_fixed32 { - ::pb_jelly::wire_format::write(7, ::pb_jelly::wire_format::Type::Fixed32, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 7, ::pb_jelly::wire_format::Type::Fixed32)?; } if let Some(ref val) = self.optional_sfixed64 { - ::pb_jelly::wire_format::write(8, ::pb_jelly::wire_format::Type::Fixed64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 8, ::pb_jelly::wire_format::Type::Fixed64)?; } if let Some(ref val) = self.optional_sfixed32 { - ::pb_jelly::wire_format::write(9, ::pb_jelly::wire_format::Type::Fixed32, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 9, ::pb_jelly::wire_format::Type::Fixed32)?; } if let Some(ref val) = self.optional_double { - ::pb_jelly::wire_format::write(10, ::pb_jelly::wire_format::Type::Fixed64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 10, ::pb_jelly::wire_format::Type::Fixed64)?; } if let Some(ref val) = self.optional_bool { - ::pb_jelly::wire_format::write(11, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 11, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.optional_string { - ::pb_jelly::wire_format::write(12, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 12, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.optional_bytes { - ::pb_jelly::wire_format::write(13, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::>(w, val, 13, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.optional_float { - ::pb_jelly::wire_format::write(14, ::pb_jelly::wire_format::Type::Fixed32, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 14, ::pb_jelly::wire_format::Type::Fixed32)?; } Ok(()) } @@ -2328,19 +2165,14 @@ impl ::pb_jelly::Message for ForeignMessage { } fn compute_size(&self) -> usize { let mut size = 0; - let mut c_size = 0; if let Some(ref val) = self.c { - let l = ::pb_jelly::Message::compute_size(val); - c_size += ::pb_jelly::wire_format::serialized_length(1); - c_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::Varint); } - size += c_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.c { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::Varint)?; } Ok(()) } @@ -3392,633 +3224,328 @@ impl ::pb_jelly::Message for TestMessage { } fn compute_size(&self) -> usize { let mut size = 0; - let mut optional_int32_size = 0; if let Some(ref val) = self.optional_int32 { - let l = ::pb_jelly::Message::compute_size(val); - optional_int32_size += ::pb_jelly::wire_format::serialized_length(1); - optional_int32_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::Varint); } - size += optional_int32_size; - let mut optional_int64_size = 0; if let Some(ref val) = self.optional_int64 { - let l = ::pb_jelly::Message::compute_size(val); - optional_int64_size += ::pb_jelly::wire_format::serialized_length(2); - optional_int64_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::Varint); } - size += optional_int64_size; - let mut optional_uint32_size = 0; if let Some(ref val) = self.optional_uint32 { - let l = ::pb_jelly::Message::compute_size(val); - optional_uint32_size += ::pb_jelly::wire_format::serialized_length(3); - optional_uint32_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::Varint); } - size += optional_uint32_size; - let mut optional_uint64_size = 0; if let Some(ref val) = self.optional_uint64 { - let l = ::pb_jelly::Message::compute_size(val); - optional_uint64_size += ::pb_jelly::wire_format::serialized_length(4); - optional_uint64_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 4, ::pb_jelly::wire_format::Type::Varint); } - size += optional_uint64_size; - let mut optional_fixed64_size = 0; if let Some(ref val) = self.optional_fixed64 { - let l = ::pb_jelly::Message::compute_size(val); - optional_fixed64_size += ::pb_jelly::wire_format::serialized_length(8); - optional_fixed64_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::pb_jelly::Fixed64>(val, 8, ::pb_jelly::wire_format::Type::Fixed64); } - size += optional_fixed64_size; - let mut optional_fixed32_size = 0; if let Some(ref val) = self.optional_fixed32 { - let l = ::pb_jelly::Message::compute_size(val); - optional_fixed32_size += ::pb_jelly::wire_format::serialized_length(9); - optional_fixed32_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::pb_jelly::Fixed32>(val, 9, ::pb_jelly::wire_format::Type::Fixed32); } - size += optional_fixed32_size; - let mut optional_sfixed64_size = 0; if let Some(ref val) = self.optional_sfixed64 { - let l = ::pb_jelly::Message::compute_size(val); - optional_sfixed64_size += ::pb_jelly::wire_format::serialized_length(10); - optional_sfixed64_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::pb_jelly::Sfixed64>(val, 10, ::pb_jelly::wire_format::Type::Fixed64); } - size += optional_sfixed64_size; - let mut optional_sfixed32_size = 0; if let Some(ref val) = self.optional_sfixed32 { - let l = ::pb_jelly::Message::compute_size(val); - optional_sfixed32_size += ::pb_jelly::wire_format::serialized_length(11); - optional_sfixed32_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::pb_jelly::Sfixed32>(val, 11, ::pb_jelly::wire_format::Type::Fixed32); } - size += optional_sfixed32_size; - let mut optional_double_size = 0; if let Some(ref val) = self.optional_double { - let l = ::pb_jelly::Message::compute_size(val); - optional_double_size += ::pb_jelly::wire_format::serialized_length(12); - optional_double_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 12, ::pb_jelly::wire_format::Type::Fixed64); } - size += optional_double_size; - let mut optional_bool_size = 0; if let Some(ref val) = self.optional_bool { - let l = ::pb_jelly::Message::compute_size(val); - optional_bool_size += ::pb_jelly::wire_format::serialized_length(13); - optional_bool_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 13, ::pb_jelly::wire_format::Type::Varint); } - size += optional_bool_size; - let mut optional_string_size = 0; if let Some(ref val) = self.optional_string { - let l = ::pb_jelly::Message::compute_size(val); - optional_string_size += ::pb_jelly::wire_format::serialized_length(14); - optional_string_size += ::pb_jelly::varint::serialized_length(l as u64); - optional_string_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 14, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += optional_string_size; - let mut optional_bytes_size = 0; if let Some(ref val) = self.optional_bytes { - let l = ::pb_jelly::Message::compute_size(val); - optional_bytes_size += ::pb_jelly::wire_format::serialized_length(15); - optional_bytes_size += ::pb_jelly::varint::serialized_length(l as u64); - optional_bytes_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::vec::Vec>(val, 15, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += optional_bytes_size; - let mut optional_float_size = 0; if let Some(ref val) = self.optional_float { - let l = ::pb_jelly::Message::compute_size(val); - optional_float_size += ::pb_jelly::wire_format::serialized_length(16); - optional_float_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 16, ::pb_jelly::wire_format::Type::Fixed32); } - size += optional_float_size; - let mut optional_foreign_message_size = 0; if let Some(ref val) = self.optional_foreign_message { - let l = ::pb_jelly::Message::compute_size(val); - optional_foreign_message_size += ::pb_jelly::wire_format::serialized_length(19); - optional_foreign_message_size += ::pb_jelly::varint::serialized_length(l as u64); - optional_foreign_message_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 19, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += optional_foreign_message_size; - let mut optional_nested_enum_size = 0; if let Some(ref val) = self.optional_nested_enum { - let l = ::pb_jelly::Message::compute_size(val); - optional_nested_enum_size += ::pb_jelly::wire_format::serialized_length(21); - optional_nested_enum_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 21, ::pb_jelly::wire_format::Type::Varint); } - size += optional_nested_enum_size; - let mut optional_foreign_enum_size = 0; if let Some(ref val) = self.optional_foreign_enum { - let l = ::pb_jelly::Message::compute_size(val); - optional_foreign_enum_size += ::pb_jelly::wire_format::serialized_length(22); - optional_foreign_enum_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 22, ::pb_jelly::wire_format::Type::Varint); } - size += optional_foreign_enum_size; - let mut repeated_int32_size = 0; for val in &self.repeated_int32 { - let l = ::pb_jelly::Message::compute_size(val); - repeated_int32_size += ::pb_jelly::wire_format::serialized_length(31); - repeated_int32_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 31, ::pb_jelly::wire_format::Type::Varint); } - size += repeated_int32_size; - let mut repeated_int64_size = 0; for val in &self.repeated_int64 { - let l = ::pb_jelly::Message::compute_size(val); - repeated_int64_size += ::pb_jelly::wire_format::serialized_length(32); - repeated_int64_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 32, ::pb_jelly::wire_format::Type::Varint); } - size += repeated_int64_size; - let mut repeated_uint32_size = 0; for val in &self.repeated_uint32 { - let l = ::pb_jelly::Message::compute_size(val); - repeated_uint32_size += ::pb_jelly::wire_format::serialized_length(33); - repeated_uint32_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 33, ::pb_jelly::wire_format::Type::Varint); } - size += repeated_uint32_size; - let mut repeated_uint64_size = 0; for val in &self.repeated_uint64 { - let l = ::pb_jelly::Message::compute_size(val); - repeated_uint64_size += ::pb_jelly::wire_format::serialized_length(34); - repeated_uint64_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 34, ::pb_jelly::wire_format::Type::Varint); } - size += repeated_uint64_size; - let mut repeated_fixed64_size = 0; for val in &self.repeated_fixed64 { - let l = ::pb_jelly::Message::compute_size(val); - repeated_fixed64_size += ::pb_jelly::wire_format::serialized_length(38); - repeated_fixed64_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::pb_jelly::Fixed64>(val, 38, ::pb_jelly::wire_format::Type::Fixed64); } - size += repeated_fixed64_size; - let mut repeated_fixed32_size = 0; for val in &self.repeated_fixed32 { - let l = ::pb_jelly::Message::compute_size(val); - repeated_fixed32_size += ::pb_jelly::wire_format::serialized_length(39); - repeated_fixed32_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::pb_jelly::Fixed32>(val, 39, ::pb_jelly::wire_format::Type::Fixed32); } - size += repeated_fixed32_size; - let mut repeated_sfixed64_size = 0; for val in &self.repeated_sfixed64 { - let l = ::pb_jelly::Message::compute_size(val); - repeated_sfixed64_size += ::pb_jelly::wire_format::serialized_length(40); - repeated_sfixed64_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::pb_jelly::Sfixed64>(val, 40, ::pb_jelly::wire_format::Type::Fixed64); } - size += repeated_sfixed64_size; - let mut repeated_sfixed32_size = 0; for val in &self.repeated_sfixed32 { - let l = ::pb_jelly::Message::compute_size(val); - repeated_sfixed32_size += ::pb_jelly::wire_format::serialized_length(41); - repeated_sfixed32_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::pb_jelly::Sfixed32>(val, 41, ::pb_jelly::wire_format::Type::Fixed32); } - size += repeated_sfixed32_size; - let mut repeated_double_size = 0; for val in &self.repeated_double { - let l = ::pb_jelly::Message::compute_size(val); - repeated_double_size += ::pb_jelly::wire_format::serialized_length(42); - repeated_double_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 42, ::pb_jelly::wire_format::Type::Fixed64); } - size += repeated_double_size; - let mut repeated_bool_size = 0; for val in &self.repeated_bool { - let l = ::pb_jelly::Message::compute_size(val); - repeated_bool_size += ::pb_jelly::wire_format::serialized_length(43); - repeated_bool_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 43, ::pb_jelly::wire_format::Type::Varint); } - size += repeated_bool_size; - let mut repeated_string_size = 0; for val in &self.repeated_string { - let l = ::pb_jelly::Message::compute_size(val); - repeated_string_size += ::pb_jelly::wire_format::serialized_length(44); - repeated_string_size += ::pb_jelly::varint::serialized_length(l as u64); - repeated_string_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 44, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += repeated_string_size; - let mut repeated_bytes_size = 0; for val in &self.repeated_bytes { - let l = ::pb_jelly::Message::compute_size(val); - repeated_bytes_size += ::pb_jelly::wire_format::serialized_length(45); - repeated_bytes_size += ::pb_jelly::varint::serialized_length(l as u64); - repeated_bytes_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::vec::Vec>(val, 45, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += repeated_bytes_size; - let mut repeated_float_size = 0; for val in &self.repeated_float { - let l = ::pb_jelly::Message::compute_size(val); - repeated_float_size += ::pb_jelly::wire_format::serialized_length(46); - repeated_float_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 46, ::pb_jelly::wire_format::Type::Fixed32); } - size += repeated_float_size; - let mut repeated_foreign_message_size = 0; for val in &self.repeated_foreign_message { - let l = ::pb_jelly::Message::compute_size(val); - repeated_foreign_message_size += ::pb_jelly::wire_format::serialized_length(49); - repeated_foreign_message_size += ::pb_jelly::varint::serialized_length(l as u64); - repeated_foreign_message_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 49, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += repeated_foreign_message_size; - let mut repeated_nested_enum_size = 0; for val in &self.repeated_nested_enum { - let l = ::pb_jelly::Message::compute_size(val); - repeated_nested_enum_size += ::pb_jelly::wire_format::serialized_length(51); - repeated_nested_enum_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 51, ::pb_jelly::wire_format::Type::Varint); } - size += repeated_nested_enum_size; - let mut repeated_foreign_enum_size = 0; for val in &self.repeated_foreign_enum { - let l = ::pb_jelly::Message::compute_size(val); - repeated_foreign_enum_size += ::pb_jelly::wire_format::serialized_length(52); - repeated_foreign_enum_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 52, ::pb_jelly::wire_format::Type::Varint); } - size += repeated_foreign_enum_size; - let mut optional_foreign_message_boxed_size = 0; if let Some(ref val) = self.optional_foreign_message_boxed { let val = &**val; - let l = ::pb_jelly::Message::compute_size(val); - optional_foreign_message_boxed_size += ::pb_jelly::wire_format::serialized_length(53); - optional_foreign_message_boxed_size += ::pb_jelly::varint::serialized_length(l as u64); - optional_foreign_message_boxed_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 53, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += optional_foreign_message_boxed_size; - let mut optional_foreign_message_nonnullable_size = 0; { let val = &self.optional_foreign_message_nonnullable; - let l = ::pb_jelly::Message::compute_size(val); - optional_foreign_message_nonnullable_size += ::pb_jelly::wire_format::serialized_length(54); - optional_foreign_message_nonnullable_size += ::pb_jelly::varint::serialized_length(l as u64); - optional_foreign_message_nonnullable_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 54, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += optional_foreign_message_nonnullable_size; - let mut int1_size = 0; if let Some(TestMessage_OneofInt::Int1(ref val)) = self.oneof_int { - let l = ::pb_jelly::Message::compute_size(val); - int1_size += ::pb_jelly::wire_format::serialized_length(57); - int1_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 57, ::pb_jelly::wire_format::Type::Varint); } - size += int1_size; - let mut foreign1_size = 0; if let Some(TestMessage_OneofInt::Foreign1(ref val)) = self.oneof_int { - let l = ::pb_jelly::Message::compute_size(val); - foreign1_size += ::pb_jelly::wire_format::serialized_length(58); - foreign1_size += ::pb_jelly::varint::serialized_length(l as u64); - foreign1_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 58, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += foreign1_size; - let mut int2_size = 0; if let Some(TestMessage_OneofForeign::Int2(ref val)) = self.oneof_foreign { - let l = ::pb_jelly::Message::compute_size(val); - int2_size += ::pb_jelly::wire_format::serialized_length(59); - int2_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 59, ::pb_jelly::wire_format::Type::Varint); } - size += int2_size; - let mut foreign2_size = 0; if let Some(TestMessage_OneofForeign::Foreign2(ref val)) = self.oneof_foreign { - let l = ::pb_jelly::Message::compute_size(val); - foreign2_size += ::pb_jelly::wire_format::serialized_length(60); - foreign2_size += ::pb_jelly::varint::serialized_length(l as u64); - foreign2_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 60, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += foreign2_size; - let mut int3_size = 0; if let Some(TestMessage_OneofZero::Int3(ref val)) = self.oneof_zero { - let l = ::pb_jelly::Message::compute_size(val); - int3_size += ::pb_jelly::wire_format::serialized_length(61); - int3_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 61, ::pb_jelly::wire_format::Type::Varint); } - size += int3_size; - let mut foreign3_size = 0; if let Some(TestMessage_OneofZero::Foreign3(ref val)) = self.oneof_zero { - let l = ::pb_jelly::Message::compute_size(val); - foreign3_size += ::pb_jelly::wire_format::serialized_length(62); - foreign3_size += ::pb_jelly::varint::serialized_length(l as u64); - foreign3_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 62, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += foreign3_size; - let mut int4_size = 0; if let Some(TestMessage_OneofNull::Int4(ref val)) = self.oneof_null { - let l = ::pb_jelly::Message::compute_size(val); - int4_size += ::pb_jelly::wire_format::serialized_length(63); - int4_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 63, ::pb_jelly::wire_format::Type::Varint); } - size += int4_size; - let mut foreign4_size = 0; if let Some(TestMessage_OneofNull::Foreign4(ref val)) = self.oneof_null { - let l = ::pb_jelly::Message::compute_size(val); - foreign4_size += ::pb_jelly::wire_format::serialized_length(64); - foreign4_size += ::pb_jelly::varint::serialized_length(l as u64); - foreign4_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 64, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += foreign4_size; - let mut int5_size = 0; if let Some(TestMessage_OneofUnset::Int5(ref val)) = self.oneof_unset { - let l = ::pb_jelly::Message::compute_size(val); - int5_size += ::pb_jelly::wire_format::serialized_length(65); - int5_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 65, ::pb_jelly::wire_format::Type::Varint); } - size += int5_size; - let mut foreign5_size = 0; if let Some(TestMessage_OneofUnset::Foreign5(ref val)) = self.oneof_unset { - let l = ::pb_jelly::Message::compute_size(val); - foreign5_size += ::pb_jelly::wire_format::serialized_length(66); - foreign5_size += ::pb_jelly::varint::serialized_length(l as u64); - foreign5_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 66, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += foreign5_size; - let mut int6_size = 0; if let Some(TestMessage_OneofPrimitives::Int6(ref val)) = self.oneof_primitives { - let l = ::pb_jelly::Message::compute_size(val); - int6_size += ::pb_jelly::wire_format::serialized_length(67); - int6_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 67, ::pb_jelly::wire_format::Type::Varint); } - size += int6_size; - let mut bool6_size = 0; if let Some(TestMessage_OneofPrimitives::Bool6(ref val)) = self.oneof_primitives { - let l = ::pb_jelly::Message::compute_size(val); - bool6_size += ::pb_jelly::wire_format::serialized_length(68); - bool6_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 68, ::pb_jelly::wire_format::Type::Varint); } - size += bool6_size; - let mut a_size = 0; if let TestMessage_OneofEmptyField::A = self.oneof_empty_field { let val: &::proto_google::protobuf::empty::Empty = &::std::default::Default::default(); - let l = ::pb_jelly::Message::compute_size(val); - a_size += ::pb_jelly::wire_format::serialized_length(70); - a_size += ::pb_jelly::varint::serialized_length(l as u64); - a_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::proto_google::protobuf::empty::Empty>(val, 70, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += a_size; - let mut b_size = 0; if let TestMessage_OneofEmptyField::B = self.oneof_empty_field { let val: &::proto_google::protobuf::empty::Empty = &::std::default::Default::default(); - let l = ::pb_jelly::Message::compute_size(val); - b_size += ::pb_jelly::wire_format::serialized_length(71); - b_size += ::pb_jelly::varint::serialized_length(l as u64); - b_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::proto_google::protobuf::empty::Empty>(val, 71, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += b_size; - let mut c_size = 0; if let TestMessage_OneofEmptyField::C(ref val) = self.oneof_empty_field { - let l = ::pb_jelly::Message::compute_size(val); - c_size += ::pb_jelly::wire_format::serialized_length(72); - c_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 72, ::pb_jelly::wire_format::Type::Varint); } - size += c_size; - let mut type_size = 0; if let Some(ref val) = self.r#type { - let l = ::pb_jelly::Message::compute_size(val); - type_size += ::pb_jelly::wire_format::serialized_length(73); - type_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 73, ::pb_jelly::wire_format::Type::Varint); } - size += type_size; - let mut loop_size = 0; if let Some(TestMessage_Mod::Loop(ref val)) = self.r#mod { - let l = ::pb_jelly::Message::compute_size(val); - loop_size += ::pb_jelly::wire_format::serialized_length(74); - loop_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 74, ::pb_jelly::wire_format::Type::Varint); } - size += loop_size; - let mut unsafe_size = 0; if let Some(TestMessage_Mod::Unsafe(ref val)) = self.r#mod { - let l = ::pb_jelly::Message::compute_size(val); - unsafe_size += ::pb_jelly::wire_format::serialized_length(75); - unsafe_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 75, ::pb_jelly::wire_format::Type::Varint); } - size += unsafe_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.optional_int32 { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.optional_int64 { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.optional_uint32 { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.optional_uint64 { - ::pb_jelly::wire_format::write(4, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 4, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.optional_fixed64 { - ::pb_jelly::wire_format::write(8, ::pb_jelly::wire_format::Type::Fixed64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 8, ::pb_jelly::wire_format::Type::Fixed64)?; } if let Some(ref val) = self.optional_fixed32 { - ::pb_jelly::wire_format::write(9, ::pb_jelly::wire_format::Type::Fixed32, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 9, ::pb_jelly::wire_format::Type::Fixed32)?; } if let Some(ref val) = self.optional_sfixed64 { - ::pb_jelly::wire_format::write(10, ::pb_jelly::wire_format::Type::Fixed64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 10, ::pb_jelly::wire_format::Type::Fixed64)?; } if let Some(ref val) = self.optional_sfixed32 { - ::pb_jelly::wire_format::write(11, ::pb_jelly::wire_format::Type::Fixed32, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 11, ::pb_jelly::wire_format::Type::Fixed32)?; } if let Some(ref val) = self.optional_double { - ::pb_jelly::wire_format::write(12, ::pb_jelly::wire_format::Type::Fixed64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 12, ::pb_jelly::wire_format::Type::Fixed64)?; } if let Some(ref val) = self.optional_bool { - ::pb_jelly::wire_format::write(13, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 13, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.optional_string { - ::pb_jelly::wire_format::write(14, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 14, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.optional_bytes { - ::pb_jelly::wire_format::write(15, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::>(w, val, 15, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.optional_float { - ::pb_jelly::wire_format::write(16, ::pb_jelly::wire_format::Type::Fixed32, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 16, ::pb_jelly::wire_format::Type::Fixed32)?; } if let Some(ref val) = self.optional_foreign_message { - ::pb_jelly::wire_format::write(19, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 19, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.optional_nested_enum { - ::pb_jelly::wire_format::write(21, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 21, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.optional_foreign_enum { - ::pb_jelly::wire_format::write(22, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 22, ::pb_jelly::wire_format::Type::Varint)?; } for val in &self.repeated_int32 { - ::pb_jelly::wire_format::write(31, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 31, ::pb_jelly::wire_format::Type::Varint)?; } for val in &self.repeated_int64 { - ::pb_jelly::wire_format::write(32, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 32, ::pb_jelly::wire_format::Type::Varint)?; } for val in &self.repeated_uint32 { - ::pb_jelly::wire_format::write(33, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 33, ::pb_jelly::wire_format::Type::Varint)?; } for val in &self.repeated_uint64 { - ::pb_jelly::wire_format::write(34, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 34, ::pb_jelly::wire_format::Type::Varint)?; } for val in &self.repeated_fixed64 { - ::pb_jelly::wire_format::write(38, ::pb_jelly::wire_format::Type::Fixed64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 38, ::pb_jelly::wire_format::Type::Fixed64)?; } for val in &self.repeated_fixed32 { - ::pb_jelly::wire_format::write(39, ::pb_jelly::wire_format::Type::Fixed32, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 39, ::pb_jelly::wire_format::Type::Fixed32)?; } for val in &self.repeated_sfixed64 { - ::pb_jelly::wire_format::write(40, ::pb_jelly::wire_format::Type::Fixed64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 40, ::pb_jelly::wire_format::Type::Fixed64)?; } for val in &self.repeated_sfixed32 { - ::pb_jelly::wire_format::write(41, ::pb_jelly::wire_format::Type::Fixed32, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 41, ::pb_jelly::wire_format::Type::Fixed32)?; } for val in &self.repeated_double { - ::pb_jelly::wire_format::write(42, ::pb_jelly::wire_format::Type::Fixed64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 42, ::pb_jelly::wire_format::Type::Fixed64)?; } for val in &self.repeated_bool { - ::pb_jelly::wire_format::write(43, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 43, ::pb_jelly::wire_format::Type::Varint)?; } for val in &self.repeated_string { - ::pb_jelly::wire_format::write(44, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 44, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.repeated_bytes { - ::pb_jelly::wire_format::write(45, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::>(w, val, 45, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.repeated_float { - ::pb_jelly::wire_format::write(46, ::pb_jelly::wire_format::Type::Fixed32, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 46, ::pb_jelly::wire_format::Type::Fixed32)?; } for val in &self.repeated_foreign_message { - ::pb_jelly::wire_format::write(49, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 49, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.repeated_nested_enum { - ::pb_jelly::wire_format::write(51, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 51, ::pb_jelly::wire_format::Type::Varint)?; } for val in &self.repeated_foreign_enum { - ::pb_jelly::wire_format::write(52, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 52, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.optional_foreign_message_boxed { let val = &**val; - ::pb_jelly::wire_format::write(53, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 53, ::pb_jelly::wire_format::Type::LengthDelimited)?; } { let val = &self.optional_foreign_message_nonnullable; - ::pb_jelly::wire_format::write(54, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 54, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(TestMessage_OneofInt::Int1(ref val)) = self.oneof_int { - ::pb_jelly::wire_format::write(57, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 57, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(TestMessage_OneofInt::Foreign1(ref val)) = self.oneof_int { - ::pb_jelly::wire_format::write(58, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 58, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(TestMessage_OneofForeign::Int2(ref val)) = self.oneof_foreign { - ::pb_jelly::wire_format::write(59, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 59, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(TestMessage_OneofForeign::Foreign2(ref val)) = self.oneof_foreign { - ::pb_jelly::wire_format::write(60, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 60, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(TestMessage_OneofZero::Int3(ref val)) = self.oneof_zero { - ::pb_jelly::wire_format::write(61, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 61, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(TestMessage_OneofZero::Foreign3(ref val)) = self.oneof_zero { - ::pb_jelly::wire_format::write(62, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 62, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(TestMessage_OneofNull::Int4(ref val)) = self.oneof_null { - ::pb_jelly::wire_format::write(63, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 63, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(TestMessage_OneofNull::Foreign4(ref val)) = self.oneof_null { - ::pb_jelly::wire_format::write(64, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 64, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(TestMessage_OneofUnset::Int5(ref val)) = self.oneof_unset { - ::pb_jelly::wire_format::write(65, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 65, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(TestMessage_OneofUnset::Foreign5(ref val)) = self.oneof_unset { - ::pb_jelly::wire_format::write(66, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 66, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(TestMessage_OneofPrimitives::Int6(ref val)) = self.oneof_primitives { - ::pb_jelly::wire_format::write(67, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 67, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(TestMessage_OneofPrimitives::Bool6(ref val)) = self.oneof_primitives { - ::pb_jelly::wire_format::write(68, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 68, ::pb_jelly::wire_format::Type::Varint)?; } if let TestMessage_OneofEmptyField::A = self.oneof_empty_field { let val: &::proto_google::protobuf::empty::Empty = &::std::default::Default::default(); - ::pb_jelly::wire_format::write(70, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 70, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let TestMessage_OneofEmptyField::B = self.oneof_empty_field { let val: &::proto_google::protobuf::empty::Empty = &::std::default::Default::default(); - ::pb_jelly::wire_format::write(71, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 71, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let TestMessage_OneofEmptyField::C(ref val) = self.oneof_empty_field { - ::pb_jelly::wire_format::write(72, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 72, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.r#type { - ::pb_jelly::wire_format::write(73, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 73, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(TestMessage_Mod::Loop(ref val)) = self.r#mod { - ::pb_jelly::wire_format::write(74, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 74, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(TestMessage_Mod::Unsafe(ref val)) = self.r#mod { - ::pb_jelly::wire_format::write(75, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 75, ::pb_jelly::wire_format::Type::Varint)?; } Ok(()) } diff --git a/pb-test/gen/pb-jelly/proto_pbtest/src/pbtest3.rs.expected b/pb-test/gen/pb-jelly/proto_pbtest/src/pbtest3.rs.expected index 93817e2..541f7e5 100644 --- a/pb-test/gen/pb-jelly/proto_pbtest/src/pbtest3.rs.expected +++ b/pb-test/gen/pb-jelly/proto_pbtest/src/pbtest3.rs.expected @@ -815,36 +815,20 @@ impl ::pb_jelly::Message for Version31OneOfNoneNullable { } fn compute_size(&self) -> usize { let mut size = 0; - let mut string_one_of_size = 0; if let Version31OneOfNoneNullable_TestOneof::StringOneOf(ref val) = self.test_oneof { - let l = ::pb_jelly::Message::compute_size(val); - string_one_of_size += ::pb_jelly::wire_format::serialized_length(1); - string_one_of_size += ::pb_jelly::varint::serialized_length(l as u64); - string_one_of_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += string_one_of_size; - let mut string_two_of_size = 0; if let Version31OneOfNoneNullable_TestOneof::StringTwoOf(ref val) = self.test_oneof { - let l = ::pb_jelly::Message::compute_size(val); - string_two_of_size += ::pb_jelly::wire_format::serialized_length(2); - string_two_of_size += ::pb_jelly::varint::serialized_length(l as u64); - string_two_of_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += string_two_of_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Version31OneOfNoneNullable_TestOneof::StringOneOf(ref val) = self.test_oneof { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Version31OneOfNoneNullable_TestOneof::StringTwoOf(ref val) = self.test_oneof { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -985,47 +969,26 @@ impl ::pb_jelly::Message for Version32OneOfNoneNullable { } fn compute_size(&self) -> usize { let mut size = 0; - let mut string_one_of_size = 0; if let Version32OneOfNoneNullable_TestOneof::StringOneOf(ref val) = self.test_oneof { - let l = ::pb_jelly::Message::compute_size(val); - string_one_of_size += ::pb_jelly::wire_format::serialized_length(1); - string_one_of_size += ::pb_jelly::varint::serialized_length(l as u64); - string_one_of_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += string_one_of_size; - let mut string_two_of_size = 0; if let Version32OneOfNoneNullable_TestOneof::StringTwoOf(ref val) = self.test_oneof { - let l = ::pb_jelly::Message::compute_size(val); - string_two_of_size += ::pb_jelly::wire_format::serialized_length(2); - string_two_of_size += ::pb_jelly::varint::serialized_length(l as u64); - string_two_of_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += string_two_of_size; - let mut int_one_Of_size = 0; if let Version32OneOfNoneNullable_TestOneof::IntOneOf(ref val) = self.test_oneof { - let l = ::pb_jelly::Message::compute_size(val); - int_one_Of_size += ::pb_jelly::wire_format::serialized_length(3); - int_one_Of_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::Varint); } - size += int_one_Of_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Version32OneOfNoneNullable_TestOneof::StringOneOf(ref val) = self.test_oneof { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Version32OneOfNoneNullable_TestOneof::StringTwoOf(ref val) = self.test_oneof { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Version32OneOfNoneNullable_TestOneof::IntOneOf(ref val) = self.test_oneof { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::Varint)?; } Ok(()) } @@ -1321,22 +1284,14 @@ impl ::pb_jelly::Message for Version31OneOf { } fn compute_size(&self) -> usize { let mut size = 0; - let mut string_one_of_size = 0; if let Some(Version31OneOf_TestOneof::StringOneOf(ref val)) = self.test_oneof { - let l = ::pb_jelly::Message::compute_size(val); - string_one_of_size += ::pb_jelly::wire_format::serialized_length(1); - string_one_of_size += ::pb_jelly::varint::serialized_length(l as u64); - string_one_of_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += string_one_of_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(Version31OneOf_TestOneof::StringOneOf(ref val)) = self.test_oneof { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -1443,33 +1398,20 @@ impl ::pb_jelly::Message for Version32OneOf { } fn compute_size(&self) -> usize { let mut size = 0; - let mut string_one_of_size = 0; if let Some(Version32OneOf_TestOneof::StringOneOf(ref val)) = self.test_oneof { - let l = ::pb_jelly::Message::compute_size(val); - string_one_of_size += ::pb_jelly::wire_format::serialized_length(1); - string_one_of_size += ::pb_jelly::varint::serialized_length(l as u64); - string_one_of_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += string_one_of_size; - let mut int_one_of_size = 0; if let Some(Version32OneOf_TestOneof::IntOneOf(ref val)) = self.test_oneof { - let l = ::pb_jelly::Message::compute_size(val); - int_one_of_size += ::pb_jelly::wire_format::serialized_length(2); - int_one_of_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::Varint); } - size += int_one_of_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(Version32OneOf_TestOneof::StringOneOf(ref val)) = self.test_oneof { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(Version32OneOf_TestOneof::IntOneOf(ref val)) = self.test_oneof { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::Varint)?; } Ok(()) } @@ -2766,369 +2708,219 @@ impl ::pb_jelly::Message for TestMessage3 { size += ::pb_jelly::helpers::compute_size_scalar::<::std::string::String>(&self.optional_string, 14, ::pb_jelly::wire_format::Type::LengthDelimited); size += ::pb_jelly::helpers::compute_size_scalar::<::std::vec::Vec>(&self.optional_bytes, 15, ::pb_jelly::wire_format::Type::LengthDelimited); size += ::pb_jelly::helpers::compute_size_scalar::(&self.optional_float, 16, ::pb_jelly::wire_format::Type::Fixed32); - let mut optional_foreign_message_size = 0; if let Some(ref val) = self.optional_foreign_message { - let l = ::pb_jelly::Message::compute_size(val); - optional_foreign_message_size += ::pb_jelly::wire_format::serialized_length(19); - optional_foreign_message_size += ::pb_jelly::varint::serialized_length(l as u64); - optional_foreign_message_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 19, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += optional_foreign_message_size; size += ::pb_jelly::helpers::compute_size_scalar::(&self.optional_nested_enum, 21, ::pb_jelly::wire_format::Type::Varint); size += ::pb_jelly::helpers::compute_size_scalar::(&self.optional_foreign_enum, 22, ::pb_jelly::wire_format::Type::Varint); - let mut repeated_int32_size = 0; - for val in &self.repeated_int32 { - let l = ::pb_jelly::Message::compute_size(val); - repeated_int32_size += l; - } if !self.repeated_int32.is_empty() { + let mut repeated_int32_size = 0; + for val in &self.repeated_int32 { + repeated_int32_size += ::pb_jelly::Message::compute_size(val); + } size += ::pb_jelly::wire_format::serialized_length(31); size += ::pb_jelly::varint::serialized_length(repeated_int32_size as u64); - } - size += repeated_int32_size; - let mut repeated_int64_size = 0; - for val in &self.repeated_int64 { - let l = ::pb_jelly::Message::compute_size(val); - repeated_int64_size += l; + size += repeated_int32_size; } if !self.repeated_int64.is_empty() { + let mut repeated_int64_size = 0; + for val in &self.repeated_int64 { + repeated_int64_size += ::pb_jelly::Message::compute_size(val); + } size += ::pb_jelly::wire_format::serialized_length(32); size += ::pb_jelly::varint::serialized_length(repeated_int64_size as u64); - } - size += repeated_int64_size; - let mut repeated_uint32_size = 0; - for val in &self.repeated_uint32 { - let l = ::pb_jelly::Message::compute_size(val); - repeated_uint32_size += l; + size += repeated_int64_size; } if !self.repeated_uint32.is_empty() { + let mut repeated_uint32_size = 0; + for val in &self.repeated_uint32 { + repeated_uint32_size += ::pb_jelly::Message::compute_size(val); + } size += ::pb_jelly::wire_format::serialized_length(33); size += ::pb_jelly::varint::serialized_length(repeated_uint32_size as u64); - } - size += repeated_uint32_size; - let mut repeated_uint64_size = 0; - for val in &self.repeated_uint64 { - let l = ::pb_jelly::Message::compute_size(val); - repeated_uint64_size += l; + size += repeated_uint32_size; } if !self.repeated_uint64.is_empty() { + let mut repeated_uint64_size = 0; + for val in &self.repeated_uint64 { + repeated_uint64_size += ::pb_jelly::Message::compute_size(val); + } size += ::pb_jelly::wire_format::serialized_length(34); size += ::pb_jelly::varint::serialized_length(repeated_uint64_size as u64); - } - size += repeated_uint64_size; - let mut repeated_fixed64_size = 0; - for val in &self.repeated_fixed64 { - let l = ::pb_jelly::Message::compute_size(val); - repeated_fixed64_size += l; + size += repeated_uint64_size; } if !self.repeated_fixed64.is_empty() { + let mut repeated_fixed64_size = 0; + for val in &self.repeated_fixed64 { + repeated_fixed64_size += ::pb_jelly::Message::compute_size(val); + } size += ::pb_jelly::wire_format::serialized_length(38); size += ::pb_jelly::varint::serialized_length(repeated_fixed64_size as u64); - } - size += repeated_fixed64_size; - let mut repeated_fixed32_size = 0; - for val in &self.repeated_fixed32 { - let l = ::pb_jelly::Message::compute_size(val); - repeated_fixed32_size += l; + size += repeated_fixed64_size; } if !self.repeated_fixed32.is_empty() { + let mut repeated_fixed32_size = 0; + for val in &self.repeated_fixed32 { + repeated_fixed32_size += ::pb_jelly::Message::compute_size(val); + } size += ::pb_jelly::wire_format::serialized_length(39); size += ::pb_jelly::varint::serialized_length(repeated_fixed32_size as u64); - } - size += repeated_fixed32_size; - let mut repeated_sfixed64_size = 0; - for val in &self.repeated_sfixed64 { - let l = ::pb_jelly::Message::compute_size(val); - repeated_sfixed64_size += l; + size += repeated_fixed32_size; } if !self.repeated_sfixed64.is_empty() { + let mut repeated_sfixed64_size = 0; + for val in &self.repeated_sfixed64 { + repeated_sfixed64_size += ::pb_jelly::Message::compute_size(val); + } size += ::pb_jelly::wire_format::serialized_length(40); size += ::pb_jelly::varint::serialized_length(repeated_sfixed64_size as u64); - } - size += repeated_sfixed64_size; - let mut repeated_sfixed32_size = 0; - for val in &self.repeated_sfixed32 { - let l = ::pb_jelly::Message::compute_size(val); - repeated_sfixed32_size += l; + size += repeated_sfixed64_size; } if !self.repeated_sfixed32.is_empty() { + let mut repeated_sfixed32_size = 0; + for val in &self.repeated_sfixed32 { + repeated_sfixed32_size += ::pb_jelly::Message::compute_size(val); + } size += ::pb_jelly::wire_format::serialized_length(41); size += ::pb_jelly::varint::serialized_length(repeated_sfixed32_size as u64); - } - size += repeated_sfixed32_size; - let mut repeated_double_size = 0; - for val in &self.repeated_double { - let l = ::pb_jelly::Message::compute_size(val); - repeated_double_size += l; + size += repeated_sfixed32_size; } if !self.repeated_double.is_empty() { + let mut repeated_double_size = 0; + for val in &self.repeated_double { + repeated_double_size += ::pb_jelly::Message::compute_size(val); + } size += ::pb_jelly::wire_format::serialized_length(42); size += ::pb_jelly::varint::serialized_length(repeated_double_size as u64); - } - size += repeated_double_size; - let mut repeated_bool_size = 0; - for val in &self.repeated_bool { - let l = ::pb_jelly::Message::compute_size(val); - repeated_bool_size += l; + size += repeated_double_size; } if !self.repeated_bool.is_empty() { + let mut repeated_bool_size = 0; + for val in &self.repeated_bool { + repeated_bool_size += ::pb_jelly::Message::compute_size(val); + } size += ::pb_jelly::wire_format::serialized_length(43); size += ::pb_jelly::varint::serialized_length(repeated_bool_size as u64); + size += repeated_bool_size; } - size += repeated_bool_size; - let mut repeated_string_size = 0; for val in &self.repeated_string { - let l = ::pb_jelly::Message::compute_size(val); - repeated_string_size += ::pb_jelly::wire_format::serialized_length(44); - repeated_string_size += ::pb_jelly::varint::serialized_length(l as u64); - repeated_string_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 44, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += repeated_string_size; - let mut repeated_bytes_size = 0; for val in &self.repeated_bytes { - let l = ::pb_jelly::Message::compute_size(val); - repeated_bytes_size += ::pb_jelly::wire_format::serialized_length(45); - repeated_bytes_size += ::pb_jelly::varint::serialized_length(l as u64); - repeated_bytes_size += l; - } - size += repeated_bytes_size; - let mut repeated_float_size = 0; - for val in &self.repeated_float { - let l = ::pb_jelly::Message::compute_size(val); - repeated_float_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::vec::Vec>(val, 45, ::pb_jelly::wire_format::Type::LengthDelimited); } if !self.repeated_float.is_empty() { + let mut repeated_float_size = 0; + for val in &self.repeated_float { + repeated_float_size += ::pb_jelly::Message::compute_size(val); + } size += ::pb_jelly::wire_format::serialized_length(46); size += ::pb_jelly::varint::serialized_length(repeated_float_size as u64); + size += repeated_float_size; } - size += repeated_float_size; - let mut repeated_foreign_message_size = 0; for val in &self.repeated_foreign_message { - let l = ::pb_jelly::Message::compute_size(val); - repeated_foreign_message_size += ::pb_jelly::wire_format::serialized_length(49); - repeated_foreign_message_size += ::pb_jelly::varint::serialized_length(l as u64); - repeated_foreign_message_size += l; - } - size += repeated_foreign_message_size; - let mut repeated_nested_enum_size = 0; - for val in &self.repeated_nested_enum { - let l = ::pb_jelly::Message::compute_size(val); - repeated_nested_enum_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 49, ::pb_jelly::wire_format::Type::LengthDelimited); } if !self.repeated_nested_enum.is_empty() { + let mut repeated_nested_enum_size = 0; + for val in &self.repeated_nested_enum { + repeated_nested_enum_size += ::pb_jelly::Message::compute_size(val); + } size += ::pb_jelly::wire_format::serialized_length(51); size += ::pb_jelly::varint::serialized_length(repeated_nested_enum_size as u64); - } - size += repeated_nested_enum_size; - let mut repeated_foreign_enum_size = 0; - for val in &self.repeated_foreign_enum { - let l = ::pb_jelly::Message::compute_size(val); - repeated_foreign_enum_size += l; + size += repeated_nested_enum_size; } if !self.repeated_foreign_enum.is_empty() { + let mut repeated_foreign_enum_size = 0; + for val in &self.repeated_foreign_enum { + repeated_foreign_enum_size += ::pb_jelly::Message::compute_size(val); + } size += ::pb_jelly::wire_format::serialized_length(52); size += ::pb_jelly::varint::serialized_length(repeated_foreign_enum_size as u64); + size += repeated_foreign_enum_size; } - size += repeated_foreign_enum_size; - let mut proto2_msg_size = 0; if let Some(ref val) = self.proto2_msg { - let l = ::pb_jelly::Message::compute_size(val); - proto2_msg_size += ::pb_jelly::wire_format::serialized_length(53); - proto2_msg_size += ::pb_jelly::varint::serialized_length(l as u64); - proto2_msg_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 53, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += proto2_msg_size; - let mut proto2_msg_empty_size = 0; if let Some(ref val) = self.proto2_msg_empty { - let l = ::pb_jelly::Message::compute_size(val); - proto2_msg_empty_size += ::pb_jelly::wire_format::serialized_length(54); - proto2_msg_empty_size += ::pb_jelly::varint::serialized_length(l as u64); - proto2_msg_empty_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 54, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += proto2_msg_empty_size; - let mut proto2_msg_missing_size = 0; if let Some(ref val) = self.proto2_msg_missing { - let l = ::pb_jelly::Message::compute_size(val); - proto2_msg_missing_size += ::pb_jelly::wire_format::serialized_length(55); - proto2_msg_missing_size += ::pb_jelly::varint::serialized_length(l as u64); - proto2_msg_missing_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 55, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += proto2_msg_missing_size; - let mut optional_foreign_message_boxed_size = 0; if let Some(ref val) = self.optional_foreign_message_boxed { let val = &**val; - let l = ::pb_jelly::Message::compute_size(val); - optional_foreign_message_boxed_size += ::pb_jelly::wire_format::serialized_length(56); - optional_foreign_message_boxed_size += ::pb_jelly::varint::serialized_length(l as u64); - optional_foreign_message_boxed_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 56, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += optional_foreign_message_boxed_size; - let mut optional_foreign_message_nonnullable_size = 0; { let val = &self.optional_foreign_message_nonnullable; - let l = ::pb_jelly::Message::compute_size(val); - optional_foreign_message_nonnullable_size += ::pb_jelly::wire_format::serialized_length(69); - optional_foreign_message_nonnullable_size += ::pb_jelly::varint::serialized_length(l as u64); - optional_foreign_message_nonnullable_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 69, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += optional_foreign_message_nonnullable_size; - let mut int1_size = 0; if let Some(TestMessage3_OneofInt::Int1(ref val)) = self.oneof_int { - let l = ::pb_jelly::Message::compute_size(val); - int1_size += ::pb_jelly::wire_format::serialized_length(57); - int1_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 57, ::pb_jelly::wire_format::Type::Varint); } - size += int1_size; - let mut foreign1_size = 0; if let Some(TestMessage3_OneofInt::Foreign1(ref val)) = self.oneof_int { - let l = ::pb_jelly::Message::compute_size(val); - foreign1_size += ::pb_jelly::wire_format::serialized_length(58); - foreign1_size += ::pb_jelly::varint::serialized_length(l as u64); - foreign1_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 58, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += foreign1_size; - let mut int2_size = 0; if let Some(TestMessage3_OneofForeign::Int2(ref val)) = self.oneof_foreign { - let l = ::pb_jelly::Message::compute_size(val); - int2_size += ::pb_jelly::wire_format::serialized_length(59); - int2_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 59, ::pb_jelly::wire_format::Type::Varint); } - size += int2_size; - let mut foreign2_size = 0; if let Some(TestMessage3_OneofForeign::Foreign2(ref val)) = self.oneof_foreign { - let l = ::pb_jelly::Message::compute_size(val); - foreign2_size += ::pb_jelly::wire_format::serialized_length(60); - foreign2_size += ::pb_jelly::varint::serialized_length(l as u64); - foreign2_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 60, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += foreign2_size; - let mut int3_size = 0; if let Some(TestMessage3_OneofZero::Int3(ref val)) = self.oneof_zero { - let l = ::pb_jelly::Message::compute_size(val); - int3_size += ::pb_jelly::wire_format::serialized_length(61); - int3_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 61, ::pb_jelly::wire_format::Type::Varint); } - size += int3_size; - let mut foreign3_size = 0; if let Some(TestMessage3_OneofZero::Foreign3(ref val)) = self.oneof_zero { - let l = ::pb_jelly::Message::compute_size(val); - foreign3_size += ::pb_jelly::wire_format::serialized_length(62); - foreign3_size += ::pb_jelly::varint::serialized_length(l as u64); - foreign3_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 62, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += foreign3_size; - let mut int4_size = 0; if let Some(TestMessage3_OneofNull::Int4(ref val)) = self.oneof_null { - let l = ::pb_jelly::Message::compute_size(val); - int4_size += ::pb_jelly::wire_format::serialized_length(63); - int4_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 63, ::pb_jelly::wire_format::Type::Varint); } - size += int4_size; - let mut foreign4_size = 0; if let Some(TestMessage3_OneofNull::Foreign4(ref val)) = self.oneof_null { - let l = ::pb_jelly::Message::compute_size(val); - foreign4_size += ::pb_jelly::wire_format::serialized_length(64); - foreign4_size += ::pb_jelly::varint::serialized_length(l as u64); - foreign4_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 64, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += foreign4_size; - let mut int5_size = 0; if let Some(TestMessage3_OneofUnset::Int5(ref val)) = self.oneof_unset { - let l = ::pb_jelly::Message::compute_size(val); - int5_size += ::pb_jelly::wire_format::serialized_length(65); - int5_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 65, ::pb_jelly::wire_format::Type::Varint); } - size += int5_size; - let mut foreign5_size = 0; if let Some(TestMessage3_OneofUnset::Foreign5(ref val)) = self.oneof_unset { - let l = ::pb_jelly::Message::compute_size(val); - foreign5_size += ::pb_jelly::wire_format::serialized_length(66); - foreign5_size += ::pb_jelly::varint::serialized_length(l as u64); - foreign5_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 66, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += foreign5_size; - let mut int6_size = 0; if let Some(TestMessage3_OneofPrimitives::Int6(ref val)) = self.oneof_primitives { - let l = ::pb_jelly::Message::compute_size(val); - int6_size += ::pb_jelly::wire_format::serialized_length(67); - int6_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 67, ::pb_jelly::wire_format::Type::Varint); } - size += int6_size; - let mut bool6_size = 0; if let Some(TestMessage3_OneofPrimitives::Bool6(ref val)) = self.oneof_primitives { - let l = ::pb_jelly::Message::compute_size(val); - bool6_size += ::pb_jelly::wire_format::serialized_length(68); - bool6_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 68, ::pb_jelly::wire_format::Type::Varint); } - size += bool6_size; - let mut a_size = 0; if let TestMessage3_OneofEmptyField::A = self.oneof_empty_field { let val: &::proto_google::protobuf::empty::Empty = &::std::default::Default::default(); - let l = ::pb_jelly::Message::compute_size(val); - a_size += ::pb_jelly::wire_format::serialized_length(70); - a_size += ::pb_jelly::varint::serialized_length(l as u64); - a_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::proto_google::protobuf::empty::Empty>(val, 70, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += a_size; - let mut b_size = 0; if let TestMessage3_OneofEmptyField::B = self.oneof_empty_field { let val: &::proto_google::protobuf::empty::Empty = &::std::default::Default::default(); - let l = ::pb_jelly::Message::compute_size(val); - b_size += ::pb_jelly::wire_format::serialized_length(71); - b_size += ::pb_jelly::varint::serialized_length(l as u64); - b_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::proto_google::protobuf::empty::Empty>(val, 71, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += b_size; - let mut c_size = 0; if let TestMessage3_OneofEmptyField::C(ref val) = self.oneof_empty_field { - let l = ::pb_jelly::Message::compute_size(val); - c_size += ::pb_jelly::wire_format::serialized_length(72); - c_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 72, ::pb_jelly::wire_format::Type::Varint); } - size += c_size; - let mut nested_size = 0; { let val = &self.nested; - let l = ::pb_jelly::Message::compute_size(val); - nested_size += ::pb_jelly::wire_format::serialized_length(73); - nested_size += ::pb_jelly::varint::serialized_length(l as u64); - nested_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 73, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += nested_size; - let mut nested_nullable_size = 0; if let Some(ref val) = self.nested_nullable { - let l = ::pb_jelly::Message::compute_size(val); - nested_nullable_size += ::pb_jelly::wire_format::serialized_length(74); - nested_nullable_size += ::pb_jelly::varint::serialized_length(l as u64); - nested_nullable_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 74, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += nested_nullable_size; - let mut nested_repeated_size = 0; for val in &self.nested_repeated { - let l = ::pb_jelly::Message::compute_size(val); - nested_repeated_size += ::pb_jelly::wire_format::serialized_length(75); - nested_repeated_size += ::pb_jelly::varint::serialized_length(l as u64); - nested_repeated_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 75, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += nested_repeated_size; size += ::pb_jelly::helpers::compute_size_scalar::<[u8; 4]>(&self.fixed_length, 76, ::pb_jelly::wire_format::Type::LengthDelimited); - let mut fixed_length_repeated_size = 0; for val in &self.fixed_length_repeated { - let l = ::pb_jelly::Message::compute_size(val); - fixed_length_repeated_size += ::pb_jelly::wire_format::serialized_length(77); - fixed_length_repeated_size += ::pb_jelly::varint::serialized_length(l as u64); - fixed_length_repeated_size += l; + size += ::pb_jelly::helpers::compute_size_field::<[u8; 4]>(val, 77, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += fixed_length_repeated_size; size += ::pb_jelly::helpers::compute_size_scalar::>(&self.zero_or_fixed_length, 78, ::pb_jelly::wire_format::Type::LengthDelimited); - let mut zero_or_fixed_length_repeated_size = 0; for val in &self.zero_or_fixed_length_repeated { - let l = ::pb_jelly::Message::compute_size(val); - zero_or_fixed_length_repeated_size += ::pb_jelly::wire_format::serialized_length(79); - zero_or_fixed_length_repeated_size += ::pb_jelly::varint::serialized_length(l as u64); - zero_or_fixed_length_repeated_size += l; + size += ::pb_jelly::helpers::compute_size_field::>(val, 79, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += zero_or_fixed_length_repeated_size; size } fn compute_grpc_slices_size(&self) -> usize { @@ -3164,10 +2956,7 @@ impl ::pb_jelly::Message for TestMessage3 { ::pb_jelly::helpers::serialize_scalar::>(w, &self.optional_bytes, 15, ::pb_jelly::wire_format::Type::LengthDelimited)?; ::pb_jelly::helpers::serialize_scalar::(w, &self.optional_float, 16, ::pb_jelly::wire_format::Type::Fixed32)?; if let Some(ref val) = self.optional_foreign_message { - ::pb_jelly::wire_format::write(19, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 19, ::pb_jelly::wire_format::Type::LengthDelimited)?; } ::pb_jelly::helpers::serialize_scalar::(w, &self.optional_nested_enum, 21, ::pb_jelly::wire_format::Type::Varint)?; ::pb_jelly::helpers::serialize_scalar::(w, &self.optional_foreign_enum, 22, ::pb_jelly::wire_format::Type::Varint)?; @@ -3178,9 +2967,9 @@ impl ::pb_jelly::Message for TestMessage3 { } ::pb_jelly::wire_format::write(31, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; ::pb_jelly::varint::write(size as u64, w)?; - } - for val in &self.repeated_int32 { - ::pb_jelly::Message::serialize(val, w)?; + for val in &self.repeated_int32 { + ::pb_jelly::Message::serialize(val, w)?; + } } if !self.repeated_int64.is_empty() { let mut size = 0; @@ -3189,9 +2978,9 @@ impl ::pb_jelly::Message for TestMessage3 { } ::pb_jelly::wire_format::write(32, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; ::pb_jelly::varint::write(size as u64, w)?; - } - for val in &self.repeated_int64 { - ::pb_jelly::Message::serialize(val, w)?; + for val in &self.repeated_int64 { + ::pb_jelly::Message::serialize(val, w)?; + } } if !self.repeated_uint32.is_empty() { let mut size = 0; @@ -3200,9 +2989,9 @@ impl ::pb_jelly::Message for TestMessage3 { } ::pb_jelly::wire_format::write(33, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; ::pb_jelly::varint::write(size as u64, w)?; - } - for val in &self.repeated_uint32 { - ::pb_jelly::Message::serialize(val, w)?; + for val in &self.repeated_uint32 { + ::pb_jelly::Message::serialize(val, w)?; + } } if !self.repeated_uint64.is_empty() { let mut size = 0; @@ -3211,9 +3000,9 @@ impl ::pb_jelly::Message for TestMessage3 { } ::pb_jelly::wire_format::write(34, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; ::pb_jelly::varint::write(size as u64, w)?; - } - for val in &self.repeated_uint64 { - ::pb_jelly::Message::serialize(val, w)?; + for val in &self.repeated_uint64 { + ::pb_jelly::Message::serialize(val, w)?; + } } if !self.repeated_fixed64.is_empty() { let mut size = 0; @@ -3222,9 +3011,9 @@ impl ::pb_jelly::Message for TestMessage3 { } ::pb_jelly::wire_format::write(38, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; ::pb_jelly::varint::write(size as u64, w)?; - } - for val in &self.repeated_fixed64 { - ::pb_jelly::Message::serialize(val, w)?; + for val in &self.repeated_fixed64 { + ::pb_jelly::Message::serialize(val, w)?; + } } if !self.repeated_fixed32.is_empty() { let mut size = 0; @@ -3233,9 +3022,9 @@ impl ::pb_jelly::Message for TestMessage3 { } ::pb_jelly::wire_format::write(39, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; ::pb_jelly::varint::write(size as u64, w)?; - } - for val in &self.repeated_fixed32 { - ::pb_jelly::Message::serialize(val, w)?; + for val in &self.repeated_fixed32 { + ::pb_jelly::Message::serialize(val, w)?; + } } if !self.repeated_sfixed64.is_empty() { let mut size = 0; @@ -3244,9 +3033,9 @@ impl ::pb_jelly::Message for TestMessage3 { } ::pb_jelly::wire_format::write(40, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; ::pb_jelly::varint::write(size as u64, w)?; - } - for val in &self.repeated_sfixed64 { - ::pb_jelly::Message::serialize(val, w)?; + for val in &self.repeated_sfixed64 { + ::pb_jelly::Message::serialize(val, w)?; + } } if !self.repeated_sfixed32.is_empty() { let mut size = 0; @@ -3255,9 +3044,9 @@ impl ::pb_jelly::Message for TestMessage3 { } ::pb_jelly::wire_format::write(41, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; ::pb_jelly::varint::write(size as u64, w)?; - } - for val in &self.repeated_sfixed32 { - ::pb_jelly::Message::serialize(val, w)?; + for val in &self.repeated_sfixed32 { + ::pb_jelly::Message::serialize(val, w)?; + } } if !self.repeated_double.is_empty() { let mut size = 0; @@ -3266,9 +3055,9 @@ impl ::pb_jelly::Message for TestMessage3 { } ::pb_jelly::wire_format::write(42, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; ::pb_jelly::varint::write(size as u64, w)?; - } - for val in &self.repeated_double { - ::pb_jelly::Message::serialize(val, w)?; + for val in &self.repeated_double { + ::pb_jelly::Message::serialize(val, w)?; + } } if !self.repeated_bool.is_empty() { let mut size = 0; @@ -3277,21 +3066,15 @@ impl ::pb_jelly::Message for TestMessage3 { } ::pb_jelly::wire_format::write(43, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; ::pb_jelly::varint::write(size as u64, w)?; - } - for val in &self.repeated_bool { - ::pb_jelly::Message::serialize(val, w)?; + for val in &self.repeated_bool { + ::pb_jelly::Message::serialize(val, w)?; + } } for val in &self.repeated_string { - ::pb_jelly::wire_format::write(44, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 44, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.repeated_bytes { - ::pb_jelly::wire_format::write(45, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::>(w, val, 45, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if !self.repeated_float.is_empty() { let mut size = 0; @@ -3300,15 +3083,12 @@ impl ::pb_jelly::Message for TestMessage3 { } ::pb_jelly::wire_format::write(46, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; ::pb_jelly::varint::write(size as u64, w)?; - } - for val in &self.repeated_float { - ::pb_jelly::Message::serialize(val, w)?; + for val in &self.repeated_float { + ::pb_jelly::Message::serialize(val, w)?; + } } for val in &self.repeated_foreign_message { - ::pb_jelly::wire_format::write(49, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 49, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if !self.repeated_nested_enum.is_empty() { let mut size = 0; @@ -3317,9 +3097,9 @@ impl ::pb_jelly::Message for TestMessage3 { } ::pb_jelly::wire_format::write(51, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; ::pb_jelly::varint::write(size as u64, w)?; - } - for val in &self.repeated_nested_enum { - ::pb_jelly::Message::serialize(val, w)?; + for val in &self.repeated_nested_enum { + ::pb_jelly::Message::serialize(val, w)?; + } } if !self.repeated_foreign_enum.is_empty() { let mut size = 0; @@ -3328,150 +3108,91 @@ impl ::pb_jelly::Message for TestMessage3 { } ::pb_jelly::wire_format::write(52, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; ::pb_jelly::varint::write(size as u64, w)?; - } - for val in &self.repeated_foreign_enum { - ::pb_jelly::Message::serialize(val, w)?; + for val in &self.repeated_foreign_enum { + ::pb_jelly::Message::serialize(val, w)?; + } } if let Some(ref val) = self.proto2_msg { - ::pb_jelly::wire_format::write(53, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 53, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.proto2_msg_empty { - ::pb_jelly::wire_format::write(54, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 54, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.proto2_msg_missing { - ::pb_jelly::wire_format::write(55, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 55, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.optional_foreign_message_boxed { let val = &**val; - ::pb_jelly::wire_format::write(56, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 56, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(TestMessage3_OneofInt::Int1(ref val)) = self.oneof_int { - ::pb_jelly::wire_format::write(57, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 57, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(TestMessage3_OneofInt::Foreign1(ref val)) = self.oneof_int { - ::pb_jelly::wire_format::write(58, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 58, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(TestMessage3_OneofForeign::Int2(ref val)) = self.oneof_foreign { - ::pb_jelly::wire_format::write(59, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 59, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(TestMessage3_OneofForeign::Foreign2(ref val)) = self.oneof_foreign { - ::pb_jelly::wire_format::write(60, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 60, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(TestMessage3_OneofZero::Int3(ref val)) = self.oneof_zero { - ::pb_jelly::wire_format::write(61, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 61, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(TestMessage3_OneofZero::Foreign3(ref val)) = self.oneof_zero { - ::pb_jelly::wire_format::write(62, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 62, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(TestMessage3_OneofNull::Int4(ref val)) = self.oneof_null { - ::pb_jelly::wire_format::write(63, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 63, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(TestMessage3_OneofNull::Foreign4(ref val)) = self.oneof_null { - ::pb_jelly::wire_format::write(64, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 64, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(TestMessage3_OneofUnset::Int5(ref val)) = self.oneof_unset { - ::pb_jelly::wire_format::write(65, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 65, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(TestMessage3_OneofUnset::Foreign5(ref val)) = self.oneof_unset { - ::pb_jelly::wire_format::write(66, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 66, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(TestMessage3_OneofPrimitives::Int6(ref val)) = self.oneof_primitives { - ::pb_jelly::wire_format::write(67, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 67, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(TestMessage3_OneofPrimitives::Bool6(ref val)) = self.oneof_primitives { - ::pb_jelly::wire_format::write(68, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 68, ::pb_jelly::wire_format::Type::Varint)?; } { let val = &self.optional_foreign_message_nonnullable; - ::pb_jelly::wire_format::write(69, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 69, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let TestMessage3_OneofEmptyField::A = self.oneof_empty_field { let val: &::proto_google::protobuf::empty::Empty = &::std::default::Default::default(); - ::pb_jelly::wire_format::write(70, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 70, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let TestMessage3_OneofEmptyField::B = self.oneof_empty_field { let val: &::proto_google::protobuf::empty::Empty = &::std::default::Default::default(); - ::pb_jelly::wire_format::write(71, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 71, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let TestMessage3_OneofEmptyField::C(ref val) = self.oneof_empty_field { - ::pb_jelly::wire_format::write(72, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 72, ::pb_jelly::wire_format::Type::Varint)?; } { let val = &self.nested; - ::pb_jelly::wire_format::write(73, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 73, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.nested_nullable { - ::pb_jelly::wire_format::write(74, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 74, ::pb_jelly::wire_format::Type::LengthDelimited)?; } for val in &self.nested_repeated { - ::pb_jelly::wire_format::write(75, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 75, ::pb_jelly::wire_format::Type::LengthDelimited)?; } ::pb_jelly::helpers::serialize_scalar::(w, &self.fixed_length, 76, ::pb_jelly::wire_format::Type::LengthDelimited)?; for val in &self.fixed_length_repeated { - ::pb_jelly::wire_format::write(77, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 77, ::pb_jelly::wire_format::Type::LengthDelimited)?; } ::pb_jelly::helpers::serialize_scalar::>(w, &self.zero_or_fixed_length, 78, ::pb_jelly::wire_format::Type::LengthDelimited)?; for val in &self.zero_or_fixed_length_repeated { - ::pb_jelly::wire_format::write(79, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::>(w, val, 79, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -4178,58 +3899,32 @@ impl ::pb_jelly::Message for TestMessage3_NestedMessage { } fn compute_size(&self) -> usize { let mut size = 0; - let mut f_size = 0; if let TestMessage3_NestedMessage_NestedOneof::F(ref val) = self.nested_oneof { - let l = ::pb_jelly::Message::compute_size(val); - f_size += ::pb_jelly::wire_format::serialized_length(3); - f_size += ::pb_jelly::varint::serialized_length(l as u64); - f_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += f_size; - let mut d_size = 0; if let TestMessage3_NestedMessage_NestedOneof::D(ref val) = self.nested_oneof { - let l = ::pb_jelly::Message::compute_size(val); - d_size += ::pb_jelly::wire_format::serialized_length(4); - d_size += ::pb_jelly::varint::serialized_length(l as u64); - d_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 4, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += d_size; - let mut e_size = 0; if let TestMessage3_NestedMessage_NestedOneof::E(ref val) = self.nested_oneof { - let l = ::pb_jelly::Message::compute_size(val); - e_size += ::pb_jelly::wire_format::serialized_length(5); - e_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 5, ::pb_jelly::wire_format::Type::Varint); } - size += e_size; - let mut n_size = 0; if let TestMessage3_NestedMessage_NestedOneof::N(ref val) = self.nested_oneof { - let l = ::pb_jelly::Message::compute_size(val); - n_size += ::pb_jelly::wire_format::serialized_length(6); - n_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 6, ::pb_jelly::wire_format::Type::Varint); } - size += n_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let TestMessage3_NestedMessage_NestedOneof::F(ref val) = self.nested_oneof { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let TestMessage3_NestedMessage_NestedOneof::D(ref val) = self.nested_oneof { - ::pb_jelly::wire_format::write(4, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 4, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let TestMessage3_NestedMessage_NestedOneof::E(ref val) = self.nested_oneof { - ::pb_jelly::wire_format::write(5, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 5, ::pb_jelly::wire_format::Type::Varint)?; } if let TestMessage3_NestedMessage_NestedOneof::N(ref val) = self.nested_oneof { - ::pb_jelly::wire_format::write(6, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 6, ::pb_jelly::wire_format::Type::Varint)?; } Ok(()) } @@ -4392,23 +4087,15 @@ impl ::pb_jelly::Message for TestMessage3_NestedMessage_File { } fn compute_size(&self) -> usize { let mut size = 0; - let mut blocklist_size = 0; for val in &self.blocklist { - let l = ::pb_jelly::Message::compute_size(val); - blocklist_size += ::pb_jelly::wire_format::serialized_length(1); - blocklist_size += ::pb_jelly::varint::serialized_length(l as u64); - blocklist_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::vec::Vec>(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += blocklist_size; size += ::pb_jelly::helpers::compute_size_scalar::(&self.size, 2, ::pb_jelly::wire_format::Type::Varint); size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { for val in &self.blocklist { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::>(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } ::pb_jelly::helpers::serialize_scalar::(w, &self.size, 2, ::pb_jelly::wire_format::Type::Varint)?; Ok(()) @@ -4548,24 +4235,16 @@ impl ::pb_jelly::Message for TestBoxedNonnullable { } fn compute_size(&self) -> usize { let mut size = 0; - let mut field_size = 0; { let val = &*self.field; - let l = ::pb_jelly::Message::compute_size(val); - field_size += ::pb_jelly::wire_format::serialized_length(1); - field_size += ::pb_jelly::varint::serialized_length(l as u64); - field_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += field_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { { let val = &*self.field; - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -4668,31 +4347,21 @@ impl ::pb_jelly::Message for TestMessage3NonNullableOneof { } fn compute_size(&self) -> usize { let mut size = 0; - let mut a_size = 0; if let TestMessage3NonNullableOneof_NonNullableOneof::A(ref val) = self.non_nullable_oneof { - let l = ::pb_jelly::Message::compute_size(val); - a_size += ::pb_jelly::wire_format::serialized_length(1); - a_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::Varint); } - size += a_size; - let mut b_size = 0; if let TestMessage3NonNullableOneof_NonNullableOneof::B(ref val) = self.non_nullable_oneof { - let l = ::pb_jelly::Message::compute_size(val); - b_size += ::pb_jelly::wire_format::serialized_length(2); - b_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::Varint); } - size += b_size; size += ::pb_jelly::helpers::compute_size_scalar::(&self.other_field, 3, ::pb_jelly::wire_format::Type::Varint); size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let TestMessage3NonNullableOneof_NonNullableOneof::A(ref val) = self.non_nullable_oneof { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::Varint)?; } if let TestMessage3NonNullableOneof_NonNullableOneof::B(ref val) = self.non_nullable_oneof { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::Varint)?; } ::pb_jelly::helpers::serialize_scalar::(w, &self.other_field, 3, ::pb_jelly::wire_format::Type::Varint)?; Ok(()) @@ -4814,18 +4483,13 @@ impl ::pb_jelly::Message for TestMessage3ErrIfDefaultEnum { } fn compute_size(&self) -> usize { let mut size = 0; - let mut field_size = 0; let val = &self.field; - let l = ::pb_jelly::Message::compute_size(val); - field_size += ::pb_jelly::wire_format::serialized_length(1); - field_size += l; - size += field_size; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::Varint); size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { let val = &self.field; - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::Varint)?; Ok(()) } fn deserialize(&mut self, mut buf: &mut B) -> ::std::io::Result<()> { @@ -4922,33 +4586,20 @@ impl ::pb_jelly::Message for TestMessage3ErrIfDefaultEnumOneof { } fn compute_size(&self) -> usize { let mut size = 0; - let mut something_size = 0; if let Some(TestMessage3ErrIfDefaultEnumOneof_Maybe::Something(ref val)) = self.maybe { - let l = ::pb_jelly::Message::compute_size(val); - something_size += ::pb_jelly::wire_format::serialized_length(1); - something_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::Varint); } - size += something_size; - let mut nothing_size = 0; if let Some(ref val) = self.nothing { - let l = ::pb_jelly::Message::compute_size(val); - nothing_size += ::pb_jelly::wire_format::serialized_length(2); - nothing_size += ::pb_jelly::varint::serialized_length(l as u64); - nothing_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::proto_google::protobuf::empty::Empty>(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += nothing_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(TestMessage3ErrIfDefaultEnumOneof_Maybe::Something(ref val)) = self.maybe { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.nothing { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -5045,16 +4696,15 @@ impl ::pb_jelly::Message for TestMessage3RepeatedErrIfDefaultEnum { } fn compute_size(&self) -> usize { let mut size = 0; - let mut field_size = 0; - for val in &self.field { - let l = ::pb_jelly::Message::compute_size(val); - field_size += l; - } if !self.field.is_empty() { + let mut field_size = 0; + for val in &self.field { + field_size += ::pb_jelly::Message::compute_size(val); + } size += ::pb_jelly::wire_format::serialized_length(1); size += ::pb_jelly::varint::serialized_length(field_size as u64); + size += field_size; } - size += field_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { @@ -5065,9 +4715,9 @@ impl ::pb_jelly::Message for TestMessage3RepeatedErrIfDefaultEnum { } ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; ::pb_jelly::varint::write(size as u64, w)?; - } - for val in &self.field { - ::pb_jelly::Message::serialize(val, w)?; + for val in &self.field { + ::pb_jelly::Message::serialize(val, w)?; + } } Ok(()) } @@ -5297,24 +4947,16 @@ impl ::pb_jelly::Message for TestMessage3NonOptionalBoxedMessage { } fn compute_size(&self) -> usize { let mut size = 0; - let mut msg_size = 0; { let val = &*self.msg; - let l = ::pb_jelly::Message::compute_size(val); - msg_size += ::pb_jelly::wire_format::serialized_length(1); - msg_size += ::pb_jelly::varint::serialized_length(l as u64); - msg_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += msg_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { { let val = &*self.msg; - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -6481,227 +6123,116 @@ impl ::pb_jelly::Message for TestProto3Optional { } fn compute_size(&self) -> usize { let mut size = 0; - let mut a_message_size = 0; if let Some(ref val) = self.a_message { - let l = ::pb_jelly::Message::compute_size(val); - a_message_size += ::pb_jelly::wire_format::serialized_length(1); - a_message_size += ::pb_jelly::varint::serialized_length(l as u64); - a_message_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += a_message_size; - let mut a_int32_size = 0; if let Some(ref val) = self.a_int32 { - let l = ::pb_jelly::Message::compute_size(val); - a_int32_size += ::pb_jelly::wire_format::serialized_length(2); - a_int32_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 2, ::pb_jelly::wire_format::Type::Varint); } - size += a_int32_size; - let mut a_int64_size = 0; if let Some(ref val) = self.a_int64 { - let l = ::pb_jelly::Message::compute_size(val); - a_int64_size += ::pb_jelly::wire_format::serialized_length(3); - a_int64_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 3, ::pb_jelly::wire_format::Type::Varint); } - size += a_int64_size; - let mut a_uint32_size = 0; if let Some(ref val) = self.a_uint32 { - let l = ::pb_jelly::Message::compute_size(val); - a_uint32_size += ::pb_jelly::wire_format::serialized_length(4); - a_uint32_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 4, ::pb_jelly::wire_format::Type::Varint); } - size += a_uint32_size; - let mut a_uint64_size = 0; if let Some(ref val) = self.a_uint64 { - let l = ::pb_jelly::Message::compute_size(val); - a_uint64_size += ::pb_jelly::wire_format::serialized_length(5); - a_uint64_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 5, ::pb_jelly::wire_format::Type::Varint); } - size += a_uint64_size; - let mut a_fixed64_size = 0; if let Some(ref val) = self.a_fixed64 { - let l = ::pb_jelly::Message::compute_size(val); - a_fixed64_size += ::pb_jelly::wire_format::serialized_length(6); - a_fixed64_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::pb_jelly::Fixed64>(val, 6, ::pb_jelly::wire_format::Type::Fixed64); } - size += a_fixed64_size; - let mut a_fixed32_size = 0; if let Some(ref val) = self.a_fixed32 { - let l = ::pb_jelly::Message::compute_size(val); - a_fixed32_size += ::pb_jelly::wire_format::serialized_length(7); - a_fixed32_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::pb_jelly::Fixed32>(val, 7, ::pb_jelly::wire_format::Type::Fixed32); } - size += a_fixed32_size; - let mut a_sfixed64_size = 0; if let Some(ref val) = self.a_sfixed64 { - let l = ::pb_jelly::Message::compute_size(val); - a_sfixed64_size += ::pb_jelly::wire_format::serialized_length(8); - a_sfixed64_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::pb_jelly::Sfixed64>(val, 8, ::pb_jelly::wire_format::Type::Fixed64); } - size += a_sfixed64_size; - let mut a_sfixed32_size = 0; if let Some(ref val) = self.a_sfixed32 { - let l = ::pb_jelly::Message::compute_size(val); - a_sfixed32_size += ::pb_jelly::wire_format::serialized_length(9); - a_sfixed32_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::pb_jelly::Sfixed32>(val, 9, ::pb_jelly::wire_format::Type::Fixed32); } - size += a_sfixed32_size; - let mut a_double_size = 0; if let Some(ref val) = self.a_double { - let l = ::pb_jelly::Message::compute_size(val); - a_double_size += ::pb_jelly::wire_format::serialized_length(10); - a_double_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 10, ::pb_jelly::wire_format::Type::Fixed64); } - size += a_double_size; - let mut a_bool_size = 0; if let Some(ref val) = self.a_bool { - let l = ::pb_jelly::Message::compute_size(val); - a_bool_size += ::pb_jelly::wire_format::serialized_length(11); - a_bool_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 11, ::pb_jelly::wire_format::Type::Varint); } - size += a_bool_size; - let mut a_string_size = 0; if let Some(ref val) = self.a_string { - let l = ::pb_jelly::Message::compute_size(val); - a_string_size += ::pb_jelly::wire_format::serialized_length(12); - a_string_size += ::pb_jelly::varint::serialized_length(l as u64); - a_string_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 12, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += a_string_size; - let mut a_bytes_size = 0; if let Some(ref val) = self.a_bytes { - let l = ::pb_jelly::Message::compute_size(val); - a_bytes_size += ::pb_jelly::wire_format::serialized_length(13); - a_bytes_size += ::pb_jelly::varint::serialized_length(l as u64); - a_bytes_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::vec::Vec>(val, 13, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += a_bytes_size; - let mut a_float_size = 0; if let Some(ref val) = self.a_float { - let l = ::pb_jelly::Message::compute_size(val); - a_float_size += ::pb_jelly::wire_format::serialized_length(14); - a_float_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 14, ::pb_jelly::wire_format::Type::Fixed32); } - size += a_float_size; - let mut real_oneof_1_1_size = 0; if let Some(TestProto3Optional_RealOneof1::RealOneof11(ref val)) = self.real_oneof_1 { - let l = ::pb_jelly::Message::compute_size(val); - real_oneof_1_1_size += ::pb_jelly::wire_format::serialized_length(15); - real_oneof_1_1_size += ::pb_jelly::varint::serialized_length(l as u64); - real_oneof_1_1_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 15, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += real_oneof_1_1_size; - let mut real_oneof_1_2_size = 0; if let Some(TestProto3Optional_RealOneof1::RealOneof12(ref val)) = self.real_oneof_1 { - let l = ::pb_jelly::Message::compute_size(val); - real_oneof_1_2_size += ::pb_jelly::wire_format::serialized_length(16); - real_oneof_1_2_size += ::pb_jelly::varint::serialized_length(l as u64); - real_oneof_1_2_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 16, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += real_oneof_1_2_size; - let mut real_oneof_2_1_size = 0; if let TestProto3Optional_RealOneof2::RealOneof21(ref val) = self.real_oneof_2 { - let l = ::pb_jelly::Message::compute_size(val); - real_oneof_2_1_size += ::pb_jelly::wire_format::serialized_length(17); - real_oneof_2_1_size += ::pb_jelly::varint::serialized_length(l as u64); - real_oneof_2_1_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 17, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += real_oneof_2_1_size; - let mut real_oneof_2_2_size = 0; if let TestProto3Optional_RealOneof2::RealOneof22(ref val) = self.real_oneof_2 { - let l = ::pb_jelly::Message::compute_size(val); - real_oneof_2_2_size += ::pb_jelly::wire_format::serialized_length(18); - real_oneof_2_2_size += ::pb_jelly::varint::serialized_length(l as u64); - real_oneof_2_2_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::std::string::String>(val, 18, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += real_oneof_2_2_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.a_message { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.a_int32 { - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.a_int64 { - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.a_uint32 { - ::pb_jelly::wire_format::write(4, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 4, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.a_uint64 { - ::pb_jelly::wire_format::write(5, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 5, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.a_fixed64 { - ::pb_jelly::wire_format::write(6, ::pb_jelly::wire_format::Type::Fixed64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 6, ::pb_jelly::wire_format::Type::Fixed64)?; } if let Some(ref val) = self.a_fixed32 { - ::pb_jelly::wire_format::write(7, ::pb_jelly::wire_format::Type::Fixed32, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 7, ::pb_jelly::wire_format::Type::Fixed32)?; } if let Some(ref val) = self.a_sfixed64 { - ::pb_jelly::wire_format::write(8, ::pb_jelly::wire_format::Type::Fixed64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 8, ::pb_jelly::wire_format::Type::Fixed64)?; } if let Some(ref val) = self.a_sfixed32 { - ::pb_jelly::wire_format::write(9, ::pb_jelly::wire_format::Type::Fixed32, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 9, ::pb_jelly::wire_format::Type::Fixed32)?; } if let Some(ref val) = self.a_double { - ::pb_jelly::wire_format::write(10, ::pb_jelly::wire_format::Type::Fixed64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 10, ::pb_jelly::wire_format::Type::Fixed64)?; } if let Some(ref val) = self.a_bool { - ::pb_jelly::wire_format::write(11, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 11, ::pb_jelly::wire_format::Type::Varint)?; } if let Some(ref val) = self.a_string { - ::pb_jelly::wire_format::write(12, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 12, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.a_bytes { - ::pb_jelly::wire_format::write(13, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::>(w, val, 13, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(ref val) = self.a_float { - ::pb_jelly::wire_format::write(14, ::pb_jelly::wire_format::Type::Fixed32, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 14, ::pb_jelly::wire_format::Type::Fixed32)?; } if let Some(TestProto3Optional_RealOneof1::RealOneof11(ref val)) = self.real_oneof_1 { - ::pb_jelly::wire_format::write(15, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 15, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(TestProto3Optional_RealOneof1::RealOneof12(ref val)) = self.real_oneof_1 { - ::pb_jelly::wire_format::write(16, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 16, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let TestProto3Optional_RealOneof2::RealOneof21(ref val) = self.real_oneof_2 { - ::pb_jelly::wire_format::write(17, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 17, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let TestProto3Optional_RealOneof2::RealOneof22(ref val) = self.real_oneof_2 { - ::pb_jelly::wire_format::write(18, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 18, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -7064,14 +6595,9 @@ impl ::pb_jelly::Message for TestProto3ContainsZerocopy { } fn compute_size(&self) -> usize { let mut size = 0; - let mut inner_size = 0; if let Some(ref val) = self.inner { - let l = ::pb_jelly::Message::compute_size(val); - inner_size += ::pb_jelly::wire_format::serialized_length(1); - inner_size += ::pb_jelly::varint::serialized_length(l as u64); - inner_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += inner_size; size } fn compute_grpc_slices_size(&self) -> usize { @@ -7083,10 +6609,7 @@ impl ::pb_jelly::Message for TestProto3ContainsZerocopy { } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.inner { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -7210,86 +6733,46 @@ impl ::pb_jelly::Message for RecursiveOneof { } fn compute_size(&self) -> usize { let mut size = 0; - let mut field_size = 0; if let Some(RecursiveOneof_OneofField::Field(ref val)) = self.oneof_field { let val: &RecursiveOneof = &**val; - let l = ::pb_jelly::Message::compute_size(val); - field_size += ::pb_jelly::wire_format::serialized_length(1); - field_size += ::pb_jelly::varint::serialized_length(l as u64); - field_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += field_size; - let mut empty_size = 0; if let Some(RecursiveOneof_OneofField::Empty) = self.oneof_field { let val: &::proto_google::protobuf::empty::Empty = &::std::default::Default::default(); - let l = ::pb_jelly::Message::compute_size(val); - empty_size += ::pb_jelly::wire_format::serialized_length(2); - empty_size += ::pb_jelly::varint::serialized_length(l as u64); - empty_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::proto_google::protobuf::empty::Empty>(val, 2, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += empty_size; - let mut boxed_empty_size = 0; if let Some(RecursiveOneof_OneofField::BoxedEmpty(ref val)) = self.oneof_field { let val: &::proto_google::protobuf::empty::Empty = &**val; - let l = ::pb_jelly::Message::compute_size(val); - boxed_empty_size += ::pb_jelly::wire_format::serialized_length(3); - boxed_empty_size += ::pb_jelly::varint::serialized_length(l as u64); - boxed_empty_size += l; + size += ::pb_jelly::helpers::compute_size_field::<::proto_google::protobuf::empty::Empty>(val, 3, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += boxed_empty_size; - let mut not_boxed_size = 0; if let Some(RecursiveOneof_OneofField::NotBoxed(ref val)) = self.oneof_field { - let l = ::pb_jelly::Message::compute_size(val); - not_boxed_size += ::pb_jelly::wire_format::serialized_length(4); - not_boxed_size += ::pb_jelly::varint::serialized_length(l as u64); - not_boxed_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 4, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += not_boxed_size; - let mut boxed_size = 0; if let Some(RecursiveOneof_OneofField::Boxed(ref val)) = self.oneof_field { let val: &ForeignMessage3 = &**val; - let l = ::pb_jelly::Message::compute_size(val); - boxed_size += ::pb_jelly::wire_format::serialized_length(5); - boxed_size += ::pb_jelly::varint::serialized_length(l as u64); - boxed_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 5, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += boxed_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(RecursiveOneof_OneofField::Field(ref val)) = self.oneof_field { let val: &RecursiveOneof = &**val; - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(RecursiveOneof_OneofField::Empty) = self.oneof_field { let val: &::proto_google::protobuf::empty::Empty = &::std::default::Default::default(); - ::pb_jelly::wire_format::write(2, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 2, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(RecursiveOneof_OneofField::BoxedEmpty(ref val)) = self.oneof_field { let val: &::proto_google::protobuf::empty::Empty = &**val; - ::pb_jelly::wire_format::write(3, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 3, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(RecursiveOneof_OneofField::NotBoxed(ref val)) = self.oneof_field { - ::pb_jelly::wire_format::write(4, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 4, ::pb_jelly::wire_format::Type::LengthDelimited)?; } if let Some(RecursiveOneof_OneofField::Boxed(ref val)) = self.oneof_field { let val: &ForeignMessage3 = &**val; - ::pb_jelly::wire_format::write(5, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 5, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -7459,22 +6942,14 @@ impl ::pb_jelly::Message for MentionsKeywordPath { } fn compute_size(&self) -> usize { let mut size = 0; - let mut message_size = 0; if let Some(ref val) = self.message { - let l = ::pb_jelly::Message::compute_size(val); - message_size += ::pb_jelly::wire_format::serialized_length(1); - message_size += ::pb_jelly::varint::serialized_length(l as u64); - message_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += message_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.message { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -7556,19 +7031,14 @@ impl ::pb_jelly::Message for NonNullableOneofKeyword { } fn compute_size(&self) -> usize { let mut size = 0; - let mut a_size = 0; if let NonNullableOneofKeyword_Async::A(ref val) = self.r#async { - let l = ::pb_jelly::Message::compute_size(val); - a_size += ::pb_jelly::wire_format::serialized_length(1); - a_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::Varint); } - size += a_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let NonNullableOneofKeyword_Async::A(ref val) = self.r#async { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::Varint)?; } Ok(()) } @@ -7657,18 +7127,13 @@ impl ::pb_jelly::Message for NonNullableEnumKeyword { } fn compute_size(&self) -> usize { let mut size = 0; - let mut enum_size = 0; let val = &self.r#enum; - let l = ::pb_jelly::Message::compute_size(val); - enum_size += ::pb_jelly::wire_format::serialized_length(1); - enum_size += l; - size += enum_size; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::Varint); size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { let val = &self.r#enum; - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::Varint, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::Varint)?; Ok(()) } fn deserialize(&mut self, mut buf: &mut B) -> ::std::io::Result<()> { @@ -7747,24 +7212,16 @@ impl ::pb_jelly::Message for MutuallyRecursiveA { } fn compute_size(&self) -> usize { let mut size = 0; - let mut inner_size = 0; if let Some(ref val) = self.inner { let val = &**val; - let l = ::pb_jelly::Message::compute_size(val); - inner_size += ::pb_jelly::wire_format::serialized_length(1); - inner_size += ::pb_jelly::varint::serialized_length(l as u64); - inner_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += inner_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.inner { let val = &**val; - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -7839,24 +7296,16 @@ impl ::pb_jelly::Message for MutuallyRecursiveB { } fn compute_size(&self) -> usize { let mut size = 0; - let mut inner_size = 0; if let Some(ref val) = self.inner { let val = &**val; - let l = ::pb_jelly::Message::compute_size(val); - inner_size += ::pb_jelly::wire_format::serialized_length(1); - inner_size += ::pb_jelly::varint::serialized_length(l as u64); - inner_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += inner_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.inner { let val = &**val; - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -7931,22 +7380,14 @@ impl ::pb_jelly::Message for MutuallyRecursiveWithRepeatedA { } fn compute_size(&self) -> usize { let mut size = 0; - let mut inner_size = 0; for val in &self.inner { - let l = ::pb_jelly::Message::compute_size(val); - inner_size += ::pb_jelly::wire_format::serialized_length(1); - inner_size += ::pb_jelly::varint::serialized_length(l as u64); - inner_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += inner_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { for val in &self.inner { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -8023,22 +7464,14 @@ impl ::pb_jelly::Message for MutuallyRecursiveWithRepeatedB { } fn compute_size(&self) -> usize { let mut size = 0; - let mut inner_size = 0; if let Some(ref val) = self.inner { - let l = ::pb_jelly::Message::compute_size(val); - inner_size += ::pb_jelly::wire_format::serialized_length(1); - inner_size += ::pb_jelly::varint::serialized_length(l as u64); - inner_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += inner_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.inner { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -8113,24 +7546,16 @@ impl ::pb_jelly::Message for MutuallyRecursiveWithBoxedA { } fn compute_size(&self) -> usize { let mut size = 0; - let mut inner_size = 0; if let Some(ref val) = self.inner { let val = &**val; - let l = ::pb_jelly::Message::compute_size(val); - inner_size += ::pb_jelly::wire_format::serialized_length(1); - inner_size += ::pb_jelly::varint::serialized_length(l as u64); - inner_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += inner_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.inner { let val = &**val; - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) } @@ -8206,22 +7631,14 @@ impl ::pb_jelly::Message for MutuallyRecursiveWithBoxedB { } fn compute_size(&self) -> usize { let mut size = 0; - let mut inner_size = 0; if let Some(ref val) = self.inner { - let l = ::pb_jelly::Message::compute_size(val); - inner_size += ::pb_jelly::wire_format::serialized_length(1); - inner_size += ::pb_jelly::varint::serialized_length(l as u64); - inner_size += l; + size += ::pb_jelly::helpers::compute_size_field::(val, 1, ::pb_jelly::wire_format::Type::LengthDelimited); } - size += inner_size; size } fn serialize(&self, w: &mut W) -> ::std::io::Result<()> { if let Some(ref val) = self.inner { - ::pb_jelly::wire_format::write(1, ::pb_jelly::wire_format::Type::LengthDelimited, w)?; - let l = ::pb_jelly::Message::compute_size(val); - ::pb_jelly::varint::write(l as u64, w)?; - ::pb_jelly::Message::serialize(val, w)?; + ::pb_jelly::helpers::serialize_field::(w, val, 1, ::pb_jelly::wire_format::Type::LengthDelimited)?; } Ok(()) }