#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
use crate as wkt;
mod debug;
mod deserialize;
mod serialize;
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Api {
pub name: std::string::String,
pub methods: std::vec::Vec<crate::Method>,
pub options: std::vec::Vec<crate::Option>,
pub version: std::string::String,
pub source_context: std::option::Option<crate::SourceContext>,
pub mixins: std::vec::Vec<crate::Mixin>,
pub syntax: crate::Syntax,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl Api {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_methods<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::Method>,
{
use std::iter::Iterator;
self.methods = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_options<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::Option>,
{
use std::iter::Iterator;
self.options = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.version = v.into();
self
}
pub fn set_source_context<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::SourceContext>,
{
self.source_context = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_source_context<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::SourceContext>,
{
self.source_context = v.map(|x| x.into());
self
}
pub fn set_mixins<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::Mixin>,
{
use std::iter::Iterator;
self.mixins = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_syntax<T: std::convert::Into<crate::Syntax>>(mut self, v: T) -> Self {
self.syntax = v.into();
self
}
}
impl wkt::message::Message for Api {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.Api"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Method {
pub name: std::string::String,
pub request_type_url: std::string::String,
pub request_streaming: bool,
pub response_type_url: std::string::String,
pub response_streaming: bool,
pub options: std::vec::Vec<crate::Option>,
pub syntax: crate::Syntax,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl Method {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_request_type_url<T: std::convert::Into<std::string::String>>(
mut self,
v: T,
) -> Self {
self.request_type_url = v.into();
self
}
pub fn set_request_streaming<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.request_streaming = v.into();
self
}
pub fn set_response_type_url<T: std::convert::Into<std::string::String>>(
mut self,
v: T,
) -> Self {
self.response_type_url = v.into();
self
}
pub fn set_response_streaming<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.response_streaming = v.into();
self
}
pub fn set_options<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::Option>,
{
use std::iter::Iterator;
self.options = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_syntax<T: std::convert::Into<crate::Syntax>>(mut self, v: T) -> Self {
self.syntax = v.into();
self
}
}
impl wkt::message::Message for Method {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.Method"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Mixin {
pub name: std::string::String,
pub root: std::string::String,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl Mixin {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_root<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.root = v.into();
self
}
}
impl wkt::message::Message for Mixin {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.Mixin"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct FileDescriptorSet {
pub file: std::vec::Vec<crate::FileDescriptorProto>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl FileDescriptorSet {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_file<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::FileDescriptorProto>,
{
use std::iter::Iterator;
self.file = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for FileDescriptorSet {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.FileDescriptorSet"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct FileDescriptorProto {
pub name: std::string::String,
pub package: std::string::String,
pub dependency: std::vec::Vec<std::string::String>,
pub public_dependency: std::vec::Vec<i32>,
pub weak_dependency: std::vec::Vec<i32>,
pub message_type: std::vec::Vec<crate::DescriptorProto>,
pub enum_type: std::vec::Vec<crate::EnumDescriptorProto>,
pub service: std::vec::Vec<crate::ServiceDescriptorProto>,
pub extension: std::vec::Vec<crate::FieldDescriptorProto>,
pub options: std::option::Option<crate::FileOptions>,
pub source_code_info: std::option::Option<crate::SourceCodeInfo>,
pub syntax: std::string::String,
pub edition: crate::Edition,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl FileDescriptorProto {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_package<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.package = v.into();
self
}
pub fn set_dependency<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<std::string::String>,
{
use std::iter::Iterator;
self.dependency = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_public_dependency<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<i32>,
{
use std::iter::Iterator;
self.public_dependency = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_weak_dependency<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<i32>,
{
use std::iter::Iterator;
self.weak_dependency = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_message_type<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::DescriptorProto>,
{
use std::iter::Iterator;
self.message_type = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_enum_type<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::EnumDescriptorProto>,
{
use std::iter::Iterator;
self.enum_type = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_service<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::ServiceDescriptorProto>,
{
use std::iter::Iterator;
self.service = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_extension<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::FieldDescriptorProto>,
{
use std::iter::Iterator;
self.extension = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_options<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::FileOptions>,
{
self.options = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::FileOptions>,
{
self.options = v.map(|x| x.into());
self
}
pub fn set_source_code_info<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::SourceCodeInfo>,
{
self.source_code_info = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_source_code_info<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::SourceCodeInfo>,
{
self.source_code_info = v.map(|x| x.into());
self
}
pub fn set_syntax<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.syntax = v.into();
self
}
pub fn set_edition<T: std::convert::Into<crate::Edition>>(mut self, v: T) -> Self {
self.edition = v.into();
self
}
}
impl wkt::message::Message for FileDescriptorProto {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.FileDescriptorProto"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DescriptorProto {
pub name: std::string::String,
pub field: std::vec::Vec<crate::FieldDescriptorProto>,
pub extension: std::vec::Vec<crate::FieldDescriptorProto>,
pub nested_type: std::vec::Vec<crate::DescriptorProto>,
pub enum_type: std::vec::Vec<crate::EnumDescriptorProto>,
pub extension_range: std::vec::Vec<crate::descriptor_proto::ExtensionRange>,
pub oneof_decl: std::vec::Vec<crate::OneofDescriptorProto>,
pub options: std::option::Option<crate::MessageOptions>,
pub reserved_range: std::vec::Vec<crate::descriptor_proto::ReservedRange>,
pub reserved_name: std::vec::Vec<std::string::String>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl DescriptorProto {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_field<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::FieldDescriptorProto>,
{
use std::iter::Iterator;
self.field = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_extension<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::FieldDescriptorProto>,
{
use std::iter::Iterator;
self.extension = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_nested_type<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::DescriptorProto>,
{
use std::iter::Iterator;
self.nested_type = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_enum_type<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::EnumDescriptorProto>,
{
use std::iter::Iterator;
self.enum_type = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_extension_range<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::descriptor_proto::ExtensionRange>,
{
use std::iter::Iterator;
self.extension_range = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_oneof_decl<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::OneofDescriptorProto>,
{
use std::iter::Iterator;
self.oneof_decl = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_options<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::MessageOptions>,
{
self.options = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::MessageOptions>,
{
self.options = v.map(|x| x.into());
self
}
pub fn set_reserved_range<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::descriptor_proto::ReservedRange>,
{
use std::iter::Iterator;
self.reserved_range = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_reserved_name<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<std::string::String>,
{
use std::iter::Iterator;
self.reserved_name = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for DescriptorProto {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.DescriptorProto"
}
}
pub mod descriptor_proto {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ExtensionRange {
pub start: i32,
pub end: i32,
pub options: std::option::Option<crate::ExtensionRangeOptions>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl ExtensionRange {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_start<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.start = v.into();
self
}
pub fn set_end<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.end = v.into();
self
}
pub fn set_options<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::ExtensionRangeOptions>,
{
self.options = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::ExtensionRangeOptions>,
{
self.options = v.map(|x| x.into());
self
}
}
impl wkt::message::Message for ExtensionRange {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.DescriptorProto.ExtensionRange"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ReservedRange {
pub start: i32,
pub end: i32,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl ReservedRange {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_start<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.start = v.into();
self
}
pub fn set_end<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.end = v.into();
self
}
}
impl wkt::message::Message for ReservedRange {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.DescriptorProto.ReservedRange"
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ExtensionRangeOptions {
pub uninterpreted_option: std::vec::Vec<crate::UninterpretedOption>,
pub declaration: std::vec::Vec<crate::extension_range_options::Declaration>,
pub features: std::option::Option<crate::FeatureSet>,
pub verification: crate::extension_range_options::VerificationState,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl ExtensionRangeOptions {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_uninterpreted_option<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::UninterpretedOption>,
{
use std::iter::Iterator;
self.uninterpreted_option = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_declaration<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::extension_range_options::Declaration>,
{
use std::iter::Iterator;
self.declaration = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_features<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_features<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = v.map(|x| x.into());
self
}
pub fn set_verification<
T: std::convert::Into<crate::extension_range_options::VerificationState>,
>(
mut self,
v: T,
) -> Self {
self.verification = v.into();
self
}
}
impl wkt::message::Message for ExtensionRangeOptions {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.ExtensionRangeOptions"
}
}
pub mod extension_range_options {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Declaration {
pub number: i32,
pub full_name: std::string::String,
pub r#type: std::string::String,
pub reserved: bool,
pub repeated: bool,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl Declaration {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_number<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.number = v.into();
self
}
pub fn set_full_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.full_name = v.into();
self
}
pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.r#type = v.into();
self
}
pub fn set_reserved<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.reserved = v.into();
self
}
pub fn set_repeated<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.repeated = v.into();
self
}
}
impl wkt::message::Message for Declaration {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.ExtensionRangeOptions.Declaration"
}
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum VerificationState {
Declaration,
Unverified,
UnknownValue(verification_state::UnknownValue),
}
#[doc(hidden)]
pub mod verification_state {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl VerificationState {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Declaration => std::option::Option::Some(0),
Self::Unverified => std::option::Option::Some(1),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Declaration => std::option::Option::Some("DECLARATION"),
Self::Unverified => std::option::Option::Some("UNVERIFIED"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for VerificationState {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for VerificationState {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for VerificationState {
fn from(value: i32) -> Self {
match value {
0 => Self::Declaration,
1 => Self::Unverified,
_ => Self::UnknownValue(verification_state::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for VerificationState {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"DECLARATION" => Self::Declaration,
"UNVERIFIED" => Self::Unverified,
_ => Self::UnknownValue(verification_state::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for VerificationState {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Declaration => serializer.serialize_i32(0),
Self::Unverified => serializer.serialize_i32(1),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for VerificationState {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<VerificationState>::new(
".google.protobuf.ExtensionRangeOptions.VerificationState",
))
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct FieldDescriptorProto {
pub name: std::string::String,
pub number: i32,
pub label: crate::field_descriptor_proto::Label,
pub r#type: crate::field_descriptor_proto::Type,
pub type_name: std::string::String,
pub extendee: std::string::String,
pub default_value: std::string::String,
pub oneof_index: i32,
pub json_name: std::string::String,
pub options: std::option::Option<crate::FieldOptions>,
pub proto3_optional: bool,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl FieldDescriptorProto {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_number<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.number = v.into();
self
}
pub fn set_label<T: std::convert::Into<crate::field_descriptor_proto::Label>>(
mut self,
v: T,
) -> Self {
self.label = v.into();
self
}
pub fn set_type<T: std::convert::Into<crate::field_descriptor_proto::Type>>(
mut self,
v: T,
) -> Self {
self.r#type = v.into();
self
}
pub fn set_type_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.type_name = v.into();
self
}
pub fn set_extendee<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.extendee = v.into();
self
}
pub fn set_default_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.default_value = v.into();
self
}
pub fn set_oneof_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.oneof_index = v.into();
self
}
pub fn set_json_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.json_name = v.into();
self
}
pub fn set_options<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::FieldOptions>,
{
self.options = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::FieldOptions>,
{
self.options = v.map(|x| x.into());
self
}
pub fn set_proto3_optional<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.proto3_optional = v.into();
self
}
}
impl wkt::message::Message for FieldDescriptorProto {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.FieldDescriptorProto"
}
}
pub mod field_descriptor_proto {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum Type {
Double,
Float,
Int64,
Uint64,
Int32,
Fixed64,
Fixed32,
Bool,
String,
Group,
Message,
Bytes,
Uint32,
Enum,
Sfixed32,
Sfixed64,
Sint32,
Sint64,
UnknownValue(r#type::UnknownValue),
}
#[doc(hidden)]
pub mod r#type {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl Type {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Double => std::option::Option::Some(1),
Self::Float => std::option::Option::Some(2),
Self::Int64 => std::option::Option::Some(3),
Self::Uint64 => std::option::Option::Some(4),
Self::Int32 => std::option::Option::Some(5),
Self::Fixed64 => std::option::Option::Some(6),
Self::Fixed32 => std::option::Option::Some(7),
Self::Bool => std::option::Option::Some(8),
Self::String => std::option::Option::Some(9),
Self::Group => std::option::Option::Some(10),
Self::Message => std::option::Option::Some(11),
Self::Bytes => std::option::Option::Some(12),
Self::Uint32 => std::option::Option::Some(13),
Self::Enum => std::option::Option::Some(14),
Self::Sfixed32 => std::option::Option::Some(15),
Self::Sfixed64 => std::option::Option::Some(16),
Self::Sint32 => std::option::Option::Some(17),
Self::Sint64 => std::option::Option::Some(18),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Double => std::option::Option::Some("TYPE_DOUBLE"),
Self::Float => std::option::Option::Some("TYPE_FLOAT"),
Self::Int64 => std::option::Option::Some("TYPE_INT64"),
Self::Uint64 => std::option::Option::Some("TYPE_UINT64"),
Self::Int32 => std::option::Option::Some("TYPE_INT32"),
Self::Fixed64 => std::option::Option::Some("TYPE_FIXED64"),
Self::Fixed32 => std::option::Option::Some("TYPE_FIXED32"),
Self::Bool => std::option::Option::Some("TYPE_BOOL"),
Self::String => std::option::Option::Some("TYPE_STRING"),
Self::Group => std::option::Option::Some("TYPE_GROUP"),
Self::Message => std::option::Option::Some("TYPE_MESSAGE"),
Self::Bytes => std::option::Option::Some("TYPE_BYTES"),
Self::Uint32 => std::option::Option::Some("TYPE_UINT32"),
Self::Enum => std::option::Option::Some("TYPE_ENUM"),
Self::Sfixed32 => std::option::Option::Some("TYPE_SFIXED32"),
Self::Sfixed64 => std::option::Option::Some("TYPE_SFIXED64"),
Self::Sint32 => std::option::Option::Some("TYPE_SINT32"),
Self::Sint64 => std::option::Option::Some("TYPE_SINT64"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for Type {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for Type {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for Type {
fn from(value: i32) -> Self {
match value {
1 => Self::Double,
2 => Self::Float,
3 => Self::Int64,
4 => Self::Uint64,
5 => Self::Int32,
6 => Self::Fixed64,
7 => Self::Fixed32,
8 => Self::Bool,
9 => Self::String,
10 => Self::Group,
11 => Self::Message,
12 => Self::Bytes,
13 => Self::Uint32,
14 => Self::Enum,
15 => Self::Sfixed32,
16 => Self::Sfixed64,
17 => Self::Sint32,
18 => Self::Sint64,
_ => Self::UnknownValue(r#type::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for Type {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"TYPE_DOUBLE" => Self::Double,
"TYPE_FLOAT" => Self::Float,
"TYPE_INT64" => Self::Int64,
"TYPE_UINT64" => Self::Uint64,
"TYPE_INT32" => Self::Int32,
"TYPE_FIXED64" => Self::Fixed64,
"TYPE_FIXED32" => Self::Fixed32,
"TYPE_BOOL" => Self::Bool,
"TYPE_STRING" => Self::String,
"TYPE_GROUP" => Self::Group,
"TYPE_MESSAGE" => Self::Message,
"TYPE_BYTES" => Self::Bytes,
"TYPE_UINT32" => Self::Uint32,
"TYPE_ENUM" => Self::Enum,
"TYPE_SFIXED32" => Self::Sfixed32,
"TYPE_SFIXED64" => Self::Sfixed64,
"TYPE_SINT32" => Self::Sint32,
"TYPE_SINT64" => Self::Sint64,
_ => Self::UnknownValue(r#type::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for Type {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Double => serializer.serialize_i32(1),
Self::Float => serializer.serialize_i32(2),
Self::Int64 => serializer.serialize_i32(3),
Self::Uint64 => serializer.serialize_i32(4),
Self::Int32 => serializer.serialize_i32(5),
Self::Fixed64 => serializer.serialize_i32(6),
Self::Fixed32 => serializer.serialize_i32(7),
Self::Bool => serializer.serialize_i32(8),
Self::String => serializer.serialize_i32(9),
Self::Group => serializer.serialize_i32(10),
Self::Message => serializer.serialize_i32(11),
Self::Bytes => serializer.serialize_i32(12),
Self::Uint32 => serializer.serialize_i32(13),
Self::Enum => serializer.serialize_i32(14),
Self::Sfixed32 => serializer.serialize_i32(15),
Self::Sfixed64 => serializer.serialize_i32(16),
Self::Sint32 => serializer.serialize_i32(17),
Self::Sint64 => serializer.serialize_i32(18),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for Type {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
".google.protobuf.FieldDescriptorProto.Type",
))
}
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum Label {
Optional,
Repeated,
Required,
UnknownValue(label::UnknownValue),
}
#[doc(hidden)]
pub mod label {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl Label {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Optional => std::option::Option::Some(1),
Self::Repeated => std::option::Option::Some(3),
Self::Required => std::option::Option::Some(2),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Optional => std::option::Option::Some("LABEL_OPTIONAL"),
Self::Repeated => std::option::Option::Some("LABEL_REPEATED"),
Self::Required => std::option::Option::Some("LABEL_REQUIRED"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for Label {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for Label {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for Label {
fn from(value: i32) -> Self {
match value {
1 => Self::Optional,
2 => Self::Required,
3 => Self::Repeated,
_ => Self::UnknownValue(label::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for Label {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"LABEL_OPTIONAL" => Self::Optional,
"LABEL_REPEATED" => Self::Repeated,
"LABEL_REQUIRED" => Self::Required,
_ => Self::UnknownValue(label::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for Label {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Optional => serializer.serialize_i32(1),
Self::Repeated => serializer.serialize_i32(3),
Self::Required => serializer.serialize_i32(2),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for Label {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<Label>::new(
".google.protobuf.FieldDescriptorProto.Label",
))
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OneofDescriptorProto {
pub name: std::string::String,
pub options: std::option::Option<crate::OneofOptions>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl OneofDescriptorProto {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_options<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::OneofOptions>,
{
self.options = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::OneofOptions>,
{
self.options = v.map(|x| x.into());
self
}
}
impl wkt::message::Message for OneofDescriptorProto {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.OneofDescriptorProto"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct EnumDescriptorProto {
pub name: std::string::String,
pub value: std::vec::Vec<crate::EnumValueDescriptorProto>,
pub options: std::option::Option<crate::EnumOptions>,
pub reserved_range: std::vec::Vec<crate::enum_descriptor_proto::EnumReservedRange>,
pub reserved_name: std::vec::Vec<std::string::String>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl EnumDescriptorProto {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_value<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::EnumValueDescriptorProto>,
{
use std::iter::Iterator;
self.value = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_options<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::EnumOptions>,
{
self.options = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::EnumOptions>,
{
self.options = v.map(|x| x.into());
self
}
pub fn set_reserved_range<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::enum_descriptor_proto::EnumReservedRange>,
{
use std::iter::Iterator;
self.reserved_range = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_reserved_name<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<std::string::String>,
{
use std::iter::Iterator;
self.reserved_name = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for EnumDescriptorProto {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.EnumDescriptorProto"
}
}
pub mod enum_descriptor_proto {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct EnumReservedRange {
pub start: i32,
pub end: i32,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl EnumReservedRange {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_start<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.start = v.into();
self
}
pub fn set_end<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.end = v.into();
self
}
}
impl wkt::message::Message for EnumReservedRange {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.EnumDescriptorProto.EnumReservedRange"
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct EnumValueDescriptorProto {
pub name: std::string::String,
pub number: i32,
pub options: std::option::Option<crate::EnumValueOptions>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl EnumValueDescriptorProto {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_number<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.number = v.into();
self
}
pub fn set_options<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::EnumValueOptions>,
{
self.options = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::EnumValueOptions>,
{
self.options = v.map(|x| x.into());
self
}
}
impl wkt::message::Message for EnumValueDescriptorProto {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.EnumValueDescriptorProto"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ServiceDescriptorProto {
pub name: std::string::String,
pub method: std::vec::Vec<crate::MethodDescriptorProto>,
pub options: std::option::Option<crate::ServiceOptions>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl ServiceDescriptorProto {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_method<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::MethodDescriptorProto>,
{
use std::iter::Iterator;
self.method = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_options<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::ServiceOptions>,
{
self.options = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::ServiceOptions>,
{
self.options = v.map(|x| x.into());
self
}
}
impl wkt::message::Message for ServiceDescriptorProto {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.ServiceDescriptorProto"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct MethodDescriptorProto {
pub name: std::string::String,
pub input_type: std::string::String,
pub output_type: std::string::String,
pub options: std::option::Option<crate::MethodOptions>,
pub client_streaming: bool,
pub server_streaming: bool,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl MethodDescriptorProto {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_input_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.input_type = v.into();
self
}
pub fn set_output_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.output_type = v.into();
self
}
pub fn set_options<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::MethodOptions>,
{
self.options = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::MethodOptions>,
{
self.options = v.map(|x| x.into());
self
}
pub fn set_client_streaming<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.client_streaming = v.into();
self
}
pub fn set_server_streaming<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.server_streaming = v.into();
self
}
}
impl wkt::message::Message for MethodDescriptorProto {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.MethodDescriptorProto"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct FileOptions {
pub java_package: std::string::String,
pub java_outer_classname: std::string::String,
pub java_multiple_files: bool,
#[deprecated]
pub java_generate_equals_and_hash: bool,
pub java_string_check_utf8: bool,
pub optimize_for: crate::file_options::OptimizeMode,
pub go_package: std::string::String,
pub cc_generic_services: bool,
pub java_generic_services: bool,
pub py_generic_services: bool,
pub deprecated: bool,
pub cc_enable_arenas: bool,
pub objc_class_prefix: std::string::String,
pub csharp_namespace: std::string::String,
pub swift_prefix: std::string::String,
pub php_class_prefix: std::string::String,
pub php_namespace: std::string::String,
pub php_metadata_namespace: std::string::String,
pub ruby_package: std::string::String,
pub features: std::option::Option<crate::FeatureSet>,
pub uninterpreted_option: std::vec::Vec<crate::UninterpretedOption>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl FileOptions {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_java_package<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.java_package = v.into();
self
}
pub fn set_java_outer_classname<T: std::convert::Into<std::string::String>>(
mut self,
v: T,
) -> Self {
self.java_outer_classname = v.into();
self
}
pub fn set_java_multiple_files<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.java_multiple_files = v.into();
self
}
#[deprecated]
pub fn set_java_generate_equals_and_hash<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.java_generate_equals_and_hash = v.into();
self
}
pub fn set_java_string_check_utf8<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.java_string_check_utf8 = v.into();
self
}
pub fn set_optimize_for<T: std::convert::Into<crate::file_options::OptimizeMode>>(
mut self,
v: T,
) -> Self {
self.optimize_for = v.into();
self
}
pub fn set_go_package<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.go_package = v.into();
self
}
pub fn set_cc_generic_services<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.cc_generic_services = v.into();
self
}
pub fn set_java_generic_services<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.java_generic_services = v.into();
self
}
pub fn set_py_generic_services<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.py_generic_services = v.into();
self
}
pub fn set_deprecated<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.deprecated = v.into();
self
}
pub fn set_cc_enable_arenas<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.cc_enable_arenas = v.into();
self
}
pub fn set_objc_class_prefix<T: std::convert::Into<std::string::String>>(
mut self,
v: T,
) -> Self {
self.objc_class_prefix = v.into();
self
}
pub fn set_csharp_namespace<T: std::convert::Into<std::string::String>>(
mut self,
v: T,
) -> Self {
self.csharp_namespace = v.into();
self
}
pub fn set_swift_prefix<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.swift_prefix = v.into();
self
}
pub fn set_php_class_prefix<T: std::convert::Into<std::string::String>>(
mut self,
v: T,
) -> Self {
self.php_class_prefix = v.into();
self
}
pub fn set_php_namespace<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.php_namespace = v.into();
self
}
pub fn set_php_metadata_namespace<T: std::convert::Into<std::string::String>>(
mut self,
v: T,
) -> Self {
self.php_metadata_namespace = v.into();
self
}
pub fn set_ruby_package<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.ruby_package = v.into();
self
}
pub fn set_features<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_features<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = v.map(|x| x.into());
self
}
pub fn set_uninterpreted_option<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::UninterpretedOption>,
{
use std::iter::Iterator;
self.uninterpreted_option = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for FileOptions {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.FileOptions"
}
}
pub mod file_options {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum OptimizeMode {
Speed,
CodeSize,
LiteRuntime,
UnknownValue(optimize_mode::UnknownValue),
}
#[doc(hidden)]
pub mod optimize_mode {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl OptimizeMode {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Speed => std::option::Option::Some(1),
Self::CodeSize => std::option::Option::Some(2),
Self::LiteRuntime => std::option::Option::Some(3),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Speed => std::option::Option::Some("SPEED"),
Self::CodeSize => std::option::Option::Some("CODE_SIZE"),
Self::LiteRuntime => std::option::Option::Some("LITE_RUNTIME"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for OptimizeMode {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for OptimizeMode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for OptimizeMode {
fn from(value: i32) -> Self {
match value {
1 => Self::Speed,
2 => Self::CodeSize,
3 => Self::LiteRuntime,
_ => Self::UnknownValue(optimize_mode::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for OptimizeMode {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"SPEED" => Self::Speed,
"CODE_SIZE" => Self::CodeSize,
"LITE_RUNTIME" => Self::LiteRuntime,
_ => Self::UnknownValue(optimize_mode::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for OptimizeMode {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Speed => serializer.serialize_i32(1),
Self::CodeSize => serializer.serialize_i32(2),
Self::LiteRuntime => serializer.serialize_i32(3),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for OptimizeMode {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<OptimizeMode>::new(
".google.protobuf.FileOptions.OptimizeMode",
))
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct MessageOptions {
pub message_set_wire_format: bool,
pub no_standard_descriptor_accessor: bool,
pub deprecated: bool,
pub map_entry: bool,
#[deprecated]
pub deprecated_legacy_json_field_conflicts: bool,
pub features: std::option::Option<crate::FeatureSet>,
pub uninterpreted_option: std::vec::Vec<crate::UninterpretedOption>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl MessageOptions {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_message_set_wire_format<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.message_set_wire_format = v.into();
self
}
pub fn set_no_standard_descriptor_accessor<T: std::convert::Into<bool>>(
mut self,
v: T,
) -> Self {
self.no_standard_descriptor_accessor = v.into();
self
}
pub fn set_deprecated<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.deprecated = v.into();
self
}
pub fn set_map_entry<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.map_entry = v.into();
self
}
#[deprecated]
pub fn set_deprecated_legacy_json_field_conflicts<T: std::convert::Into<bool>>(
mut self,
v: T,
) -> Self {
self.deprecated_legacy_json_field_conflicts = v.into();
self
}
pub fn set_features<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_features<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = v.map(|x| x.into());
self
}
pub fn set_uninterpreted_option<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::UninterpretedOption>,
{
use std::iter::Iterator;
self.uninterpreted_option = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for MessageOptions {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.MessageOptions"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct FieldOptions {
pub ctype: crate::field_options::CType,
pub packed: bool,
pub jstype: crate::field_options::JSType,
pub lazy: bool,
pub unverified_lazy: bool,
pub deprecated: bool,
pub weak: bool,
pub debug_redact: bool,
pub retention: crate::field_options::OptionRetention,
pub targets: std::vec::Vec<crate::field_options::OptionTargetType>,
pub edition_defaults: std::vec::Vec<crate::field_options::EditionDefault>,
pub features: std::option::Option<crate::FeatureSet>,
pub feature_support: std::option::Option<crate::field_options::FeatureSupport>,
pub uninterpreted_option: std::vec::Vec<crate::UninterpretedOption>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl FieldOptions {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_ctype<T: std::convert::Into<crate::field_options::CType>>(mut self, v: T) -> Self {
self.ctype = v.into();
self
}
pub fn set_packed<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.packed = v.into();
self
}
pub fn set_jstype<T: std::convert::Into<crate::field_options::JSType>>(mut self, v: T) -> Self {
self.jstype = v.into();
self
}
pub fn set_lazy<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.lazy = v.into();
self
}
pub fn set_unverified_lazy<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.unverified_lazy = v.into();
self
}
pub fn set_deprecated<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.deprecated = v.into();
self
}
pub fn set_weak<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.weak = v.into();
self
}
pub fn set_debug_redact<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.debug_redact = v.into();
self
}
pub fn set_retention<T: std::convert::Into<crate::field_options::OptionRetention>>(
mut self,
v: T,
) -> Self {
self.retention = v.into();
self
}
pub fn set_targets<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::field_options::OptionTargetType>,
{
use std::iter::Iterator;
self.targets = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_edition_defaults<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::field_options::EditionDefault>,
{
use std::iter::Iterator;
self.edition_defaults = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_features<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_features<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = v.map(|x| x.into());
self
}
pub fn set_feature_support<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::field_options::FeatureSupport>,
{
self.feature_support = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_feature_support<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::field_options::FeatureSupport>,
{
self.feature_support = v.map(|x| x.into());
self
}
pub fn set_uninterpreted_option<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::UninterpretedOption>,
{
use std::iter::Iterator;
self.uninterpreted_option = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for FieldOptions {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.FieldOptions"
}
}
pub mod field_options {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct EditionDefault {
pub edition: crate::Edition,
pub value: std::string::String,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl EditionDefault {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_edition<T: std::convert::Into<crate::Edition>>(mut self, v: T) -> Self {
self.edition = v.into();
self
}
pub fn set_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.value = v.into();
self
}
}
impl wkt::message::Message for EditionDefault {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.FieldOptions.EditionDefault"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct FeatureSupport {
pub edition_introduced: crate::Edition,
pub edition_deprecated: crate::Edition,
pub deprecation_warning: std::string::String,
pub edition_removed: crate::Edition,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl FeatureSupport {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_edition_introduced<T: std::convert::Into<crate::Edition>>(
mut self,
v: T,
) -> Self {
self.edition_introduced = v.into();
self
}
pub fn set_edition_deprecated<T: std::convert::Into<crate::Edition>>(
mut self,
v: T,
) -> Self {
self.edition_deprecated = v.into();
self
}
pub fn set_deprecation_warning<T: std::convert::Into<std::string::String>>(
mut self,
v: T,
) -> Self {
self.deprecation_warning = v.into();
self
}
pub fn set_edition_removed<T: std::convert::Into<crate::Edition>>(mut self, v: T) -> Self {
self.edition_removed = v.into();
self
}
}
impl wkt::message::Message for FeatureSupport {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.FieldOptions.FeatureSupport"
}
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum CType {
String,
Cord,
StringPiece,
UnknownValue(c_type::UnknownValue),
}
#[doc(hidden)]
pub mod c_type {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl CType {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::String => std::option::Option::Some(0),
Self::Cord => std::option::Option::Some(1),
Self::StringPiece => std::option::Option::Some(2),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::String => std::option::Option::Some("STRING"),
Self::Cord => std::option::Option::Some("CORD"),
Self::StringPiece => std::option::Option::Some("STRING_PIECE"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for CType {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for CType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for CType {
fn from(value: i32) -> Self {
match value {
0 => Self::String,
1 => Self::Cord,
2 => Self::StringPiece,
_ => Self::UnknownValue(c_type::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for CType {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"STRING" => Self::String,
"CORD" => Self::Cord,
"STRING_PIECE" => Self::StringPiece,
_ => Self::UnknownValue(c_type::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for CType {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::String => serializer.serialize_i32(0),
Self::Cord => serializer.serialize_i32(1),
Self::StringPiece => serializer.serialize_i32(2),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for CType {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<CType>::new(
".google.protobuf.FieldOptions.CType",
))
}
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum JSType {
JsNormal,
JsString,
JsNumber,
UnknownValue(js_type::UnknownValue),
}
#[doc(hidden)]
pub mod js_type {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl JSType {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::JsNormal => std::option::Option::Some(0),
Self::JsString => std::option::Option::Some(1),
Self::JsNumber => std::option::Option::Some(2),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::JsNormal => std::option::Option::Some("JS_NORMAL"),
Self::JsString => std::option::Option::Some("JS_STRING"),
Self::JsNumber => std::option::Option::Some("JS_NUMBER"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for JSType {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for JSType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for JSType {
fn from(value: i32) -> Self {
match value {
0 => Self::JsNormal,
1 => Self::JsString,
2 => Self::JsNumber,
_ => Self::UnknownValue(js_type::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for JSType {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"JS_NORMAL" => Self::JsNormal,
"JS_STRING" => Self::JsString,
"JS_NUMBER" => Self::JsNumber,
_ => Self::UnknownValue(js_type::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for JSType {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::JsNormal => serializer.serialize_i32(0),
Self::JsString => serializer.serialize_i32(1),
Self::JsNumber => serializer.serialize_i32(2),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for JSType {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<JSType>::new(
".google.protobuf.FieldOptions.JSType",
))
}
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum OptionRetention {
RetentionUnknown,
RetentionRuntime,
RetentionSource,
UnknownValue(option_retention::UnknownValue),
}
#[doc(hidden)]
pub mod option_retention {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl OptionRetention {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::RetentionUnknown => std::option::Option::Some(0),
Self::RetentionRuntime => std::option::Option::Some(1),
Self::RetentionSource => std::option::Option::Some(2),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::RetentionUnknown => std::option::Option::Some("RETENTION_UNKNOWN"),
Self::RetentionRuntime => std::option::Option::Some("RETENTION_RUNTIME"),
Self::RetentionSource => std::option::Option::Some("RETENTION_SOURCE"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for OptionRetention {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for OptionRetention {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for OptionRetention {
fn from(value: i32) -> Self {
match value {
0 => Self::RetentionUnknown,
1 => Self::RetentionRuntime,
2 => Self::RetentionSource,
_ => Self::UnknownValue(option_retention::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for OptionRetention {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"RETENTION_UNKNOWN" => Self::RetentionUnknown,
"RETENTION_RUNTIME" => Self::RetentionRuntime,
"RETENTION_SOURCE" => Self::RetentionSource,
_ => Self::UnknownValue(option_retention::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for OptionRetention {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::RetentionUnknown => serializer.serialize_i32(0),
Self::RetentionRuntime => serializer.serialize_i32(1),
Self::RetentionSource => serializer.serialize_i32(2),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for OptionRetention {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<OptionRetention>::new(
".google.protobuf.FieldOptions.OptionRetention",
))
}
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum OptionTargetType {
TargetTypeUnknown,
TargetTypeFile,
TargetTypeExtensionRange,
TargetTypeMessage,
TargetTypeField,
TargetTypeOneof,
TargetTypeEnum,
TargetTypeEnumEntry,
TargetTypeService,
TargetTypeMethod,
UnknownValue(option_target_type::UnknownValue),
}
#[doc(hidden)]
pub mod option_target_type {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl OptionTargetType {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::TargetTypeUnknown => std::option::Option::Some(0),
Self::TargetTypeFile => std::option::Option::Some(1),
Self::TargetTypeExtensionRange => std::option::Option::Some(2),
Self::TargetTypeMessage => std::option::Option::Some(3),
Self::TargetTypeField => std::option::Option::Some(4),
Self::TargetTypeOneof => std::option::Option::Some(5),
Self::TargetTypeEnum => std::option::Option::Some(6),
Self::TargetTypeEnumEntry => std::option::Option::Some(7),
Self::TargetTypeService => std::option::Option::Some(8),
Self::TargetTypeMethod => std::option::Option::Some(9),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::TargetTypeUnknown => std::option::Option::Some("TARGET_TYPE_UNKNOWN"),
Self::TargetTypeFile => std::option::Option::Some("TARGET_TYPE_FILE"),
Self::TargetTypeExtensionRange => {
std::option::Option::Some("TARGET_TYPE_EXTENSION_RANGE")
}
Self::TargetTypeMessage => std::option::Option::Some("TARGET_TYPE_MESSAGE"),
Self::TargetTypeField => std::option::Option::Some("TARGET_TYPE_FIELD"),
Self::TargetTypeOneof => std::option::Option::Some("TARGET_TYPE_ONEOF"),
Self::TargetTypeEnum => std::option::Option::Some("TARGET_TYPE_ENUM"),
Self::TargetTypeEnumEntry => std::option::Option::Some("TARGET_TYPE_ENUM_ENTRY"),
Self::TargetTypeService => std::option::Option::Some("TARGET_TYPE_SERVICE"),
Self::TargetTypeMethod => std::option::Option::Some("TARGET_TYPE_METHOD"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for OptionTargetType {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for OptionTargetType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for OptionTargetType {
fn from(value: i32) -> Self {
match value {
0 => Self::TargetTypeUnknown,
1 => Self::TargetTypeFile,
2 => Self::TargetTypeExtensionRange,
3 => Self::TargetTypeMessage,
4 => Self::TargetTypeField,
5 => Self::TargetTypeOneof,
6 => Self::TargetTypeEnum,
7 => Self::TargetTypeEnumEntry,
8 => Self::TargetTypeService,
9 => Self::TargetTypeMethod,
_ => Self::UnknownValue(option_target_type::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for OptionTargetType {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"TARGET_TYPE_UNKNOWN" => Self::TargetTypeUnknown,
"TARGET_TYPE_FILE" => Self::TargetTypeFile,
"TARGET_TYPE_EXTENSION_RANGE" => Self::TargetTypeExtensionRange,
"TARGET_TYPE_MESSAGE" => Self::TargetTypeMessage,
"TARGET_TYPE_FIELD" => Self::TargetTypeField,
"TARGET_TYPE_ONEOF" => Self::TargetTypeOneof,
"TARGET_TYPE_ENUM" => Self::TargetTypeEnum,
"TARGET_TYPE_ENUM_ENTRY" => Self::TargetTypeEnumEntry,
"TARGET_TYPE_SERVICE" => Self::TargetTypeService,
"TARGET_TYPE_METHOD" => Self::TargetTypeMethod,
_ => Self::UnknownValue(option_target_type::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for OptionTargetType {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::TargetTypeUnknown => serializer.serialize_i32(0),
Self::TargetTypeFile => serializer.serialize_i32(1),
Self::TargetTypeExtensionRange => serializer.serialize_i32(2),
Self::TargetTypeMessage => serializer.serialize_i32(3),
Self::TargetTypeField => serializer.serialize_i32(4),
Self::TargetTypeOneof => serializer.serialize_i32(5),
Self::TargetTypeEnum => serializer.serialize_i32(6),
Self::TargetTypeEnumEntry => serializer.serialize_i32(7),
Self::TargetTypeService => serializer.serialize_i32(8),
Self::TargetTypeMethod => serializer.serialize_i32(9),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for OptionTargetType {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<OptionTargetType>::new(
".google.protobuf.FieldOptions.OptionTargetType",
))
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OneofOptions {
pub features: std::option::Option<crate::FeatureSet>,
pub uninterpreted_option: std::vec::Vec<crate::UninterpretedOption>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl OneofOptions {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_features<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_features<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = v.map(|x| x.into());
self
}
pub fn set_uninterpreted_option<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::UninterpretedOption>,
{
use std::iter::Iterator;
self.uninterpreted_option = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for OneofOptions {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.OneofOptions"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct EnumOptions {
pub allow_alias: bool,
pub deprecated: bool,
#[deprecated]
pub deprecated_legacy_json_field_conflicts: bool,
pub features: std::option::Option<crate::FeatureSet>,
pub uninterpreted_option: std::vec::Vec<crate::UninterpretedOption>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl EnumOptions {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_allow_alias<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.allow_alias = v.into();
self
}
pub fn set_deprecated<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.deprecated = v.into();
self
}
#[deprecated]
pub fn set_deprecated_legacy_json_field_conflicts<T: std::convert::Into<bool>>(
mut self,
v: T,
) -> Self {
self.deprecated_legacy_json_field_conflicts = v.into();
self
}
pub fn set_features<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_features<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = v.map(|x| x.into());
self
}
pub fn set_uninterpreted_option<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::UninterpretedOption>,
{
use std::iter::Iterator;
self.uninterpreted_option = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for EnumOptions {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.EnumOptions"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct EnumValueOptions {
pub deprecated: bool,
pub features: std::option::Option<crate::FeatureSet>,
pub debug_redact: bool,
pub feature_support: std::option::Option<crate::field_options::FeatureSupport>,
pub uninterpreted_option: std::vec::Vec<crate::UninterpretedOption>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl EnumValueOptions {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_deprecated<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.deprecated = v.into();
self
}
pub fn set_features<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_features<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = v.map(|x| x.into());
self
}
pub fn set_debug_redact<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.debug_redact = v.into();
self
}
pub fn set_feature_support<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::field_options::FeatureSupport>,
{
self.feature_support = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_feature_support<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::field_options::FeatureSupport>,
{
self.feature_support = v.map(|x| x.into());
self
}
pub fn set_uninterpreted_option<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::UninterpretedOption>,
{
use std::iter::Iterator;
self.uninterpreted_option = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for EnumValueOptions {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.EnumValueOptions"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ServiceOptions {
pub features: std::option::Option<crate::FeatureSet>,
pub deprecated: bool,
pub uninterpreted_option: std::vec::Vec<crate::UninterpretedOption>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl ServiceOptions {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_features<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_features<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = v.map(|x| x.into());
self
}
pub fn set_deprecated<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.deprecated = v.into();
self
}
pub fn set_uninterpreted_option<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::UninterpretedOption>,
{
use std::iter::Iterator;
self.uninterpreted_option = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for ServiceOptions {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.ServiceOptions"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct MethodOptions {
pub deprecated: bool,
pub idempotency_level: crate::method_options::IdempotencyLevel,
pub features: std::option::Option<crate::FeatureSet>,
pub uninterpreted_option: std::vec::Vec<crate::UninterpretedOption>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl MethodOptions {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_deprecated<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.deprecated = v.into();
self
}
pub fn set_idempotency_level<T: std::convert::Into<crate::method_options::IdempotencyLevel>>(
mut self,
v: T,
) -> Self {
self.idempotency_level = v.into();
self
}
pub fn set_features<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_features<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.features = v.map(|x| x.into());
self
}
pub fn set_uninterpreted_option<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::UninterpretedOption>,
{
use std::iter::Iterator;
self.uninterpreted_option = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for MethodOptions {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.MethodOptions"
}
}
pub mod method_options {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum IdempotencyLevel {
IdempotencyUnknown,
NoSideEffects,
Idempotent,
UnknownValue(idempotency_level::UnknownValue),
}
#[doc(hidden)]
pub mod idempotency_level {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl IdempotencyLevel {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::IdempotencyUnknown => std::option::Option::Some(0),
Self::NoSideEffects => std::option::Option::Some(1),
Self::Idempotent => std::option::Option::Some(2),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::IdempotencyUnknown => std::option::Option::Some("IDEMPOTENCY_UNKNOWN"),
Self::NoSideEffects => std::option::Option::Some("NO_SIDE_EFFECTS"),
Self::Idempotent => std::option::Option::Some("IDEMPOTENT"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for IdempotencyLevel {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for IdempotencyLevel {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for IdempotencyLevel {
fn from(value: i32) -> Self {
match value {
0 => Self::IdempotencyUnknown,
1 => Self::NoSideEffects,
2 => Self::Idempotent,
_ => Self::UnknownValue(idempotency_level::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for IdempotencyLevel {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"IDEMPOTENCY_UNKNOWN" => Self::IdempotencyUnknown,
"NO_SIDE_EFFECTS" => Self::NoSideEffects,
"IDEMPOTENT" => Self::Idempotent,
_ => Self::UnknownValue(idempotency_level::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for IdempotencyLevel {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::IdempotencyUnknown => serializer.serialize_i32(0),
Self::NoSideEffects => serializer.serialize_i32(1),
Self::Idempotent => serializer.serialize_i32(2),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for IdempotencyLevel {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<IdempotencyLevel>::new(
".google.protobuf.MethodOptions.IdempotencyLevel",
))
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UninterpretedOption {
pub name: std::vec::Vec<crate::uninterpreted_option::NamePart>,
pub identifier_value: std::string::String,
pub positive_int_value: u64,
pub negative_int_value: i64,
pub double_value: f64,
pub string_value: ::bytes::Bytes,
pub aggregate_value: std::string::String,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl UninterpretedOption {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::uninterpreted_option::NamePart>,
{
use std::iter::Iterator;
self.name = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_identifier_value<T: std::convert::Into<std::string::String>>(
mut self,
v: T,
) -> Self {
self.identifier_value = v.into();
self
}
pub fn set_positive_int_value<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
self.positive_int_value = v.into();
self
}
pub fn set_negative_int_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
self.negative_int_value = v.into();
self
}
pub fn set_double_value<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
self.double_value = v.into();
self
}
pub fn set_string_value<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
self.string_value = v.into();
self
}
pub fn set_aggregate_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.aggregate_value = v.into();
self
}
}
impl wkt::message::Message for UninterpretedOption {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.UninterpretedOption"
}
}
pub mod uninterpreted_option {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct NamePart {
pub name_part: std::string::String,
pub is_extension: bool,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl NamePart {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name_part<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name_part = v.into();
self
}
pub fn set_is_extension<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.is_extension = v.into();
self
}
}
impl wkt::message::Message for NamePart {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.UninterpretedOption.NamePart"
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct FeatureSet {
pub field_presence: crate::feature_set::FieldPresence,
pub enum_type: crate::feature_set::EnumType,
pub repeated_field_encoding: crate::feature_set::RepeatedFieldEncoding,
pub utf8_validation: crate::feature_set::Utf8Validation,
pub message_encoding: crate::feature_set::MessageEncoding,
pub json_format: crate::feature_set::JsonFormat,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl FeatureSet {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_field_presence<T: std::convert::Into<crate::feature_set::FieldPresence>>(
mut self,
v: T,
) -> Self {
self.field_presence = v.into();
self
}
pub fn set_enum_type<T: std::convert::Into<crate::feature_set::EnumType>>(
mut self,
v: T,
) -> Self {
self.enum_type = v.into();
self
}
pub fn set_repeated_field_encoding<
T: std::convert::Into<crate::feature_set::RepeatedFieldEncoding>,
>(
mut self,
v: T,
) -> Self {
self.repeated_field_encoding = v.into();
self
}
pub fn set_utf8_validation<T: std::convert::Into<crate::feature_set::Utf8Validation>>(
mut self,
v: T,
) -> Self {
self.utf8_validation = v.into();
self
}
pub fn set_message_encoding<T: std::convert::Into<crate::feature_set::MessageEncoding>>(
mut self,
v: T,
) -> Self {
self.message_encoding = v.into();
self
}
pub fn set_json_format<T: std::convert::Into<crate::feature_set::JsonFormat>>(
mut self,
v: T,
) -> Self {
self.json_format = v.into();
self
}
}
impl wkt::message::Message for FeatureSet {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.FeatureSet"
}
}
pub mod feature_set {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum FieldPresence {
Unknown,
Explicit,
Implicit,
LegacyRequired,
UnknownValue(field_presence::UnknownValue),
}
#[doc(hidden)]
pub mod field_presence {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl FieldPresence {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Unknown => std::option::Option::Some(0),
Self::Explicit => std::option::Option::Some(1),
Self::Implicit => std::option::Option::Some(2),
Self::LegacyRequired => std::option::Option::Some(3),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Unknown => std::option::Option::Some("FIELD_PRESENCE_UNKNOWN"),
Self::Explicit => std::option::Option::Some("EXPLICIT"),
Self::Implicit => std::option::Option::Some("IMPLICIT"),
Self::LegacyRequired => std::option::Option::Some("LEGACY_REQUIRED"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for FieldPresence {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for FieldPresence {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for FieldPresence {
fn from(value: i32) -> Self {
match value {
0 => Self::Unknown,
1 => Self::Explicit,
2 => Self::Implicit,
3 => Self::LegacyRequired,
_ => Self::UnknownValue(field_presence::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for FieldPresence {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"FIELD_PRESENCE_UNKNOWN" => Self::Unknown,
"EXPLICIT" => Self::Explicit,
"IMPLICIT" => Self::Implicit,
"LEGACY_REQUIRED" => Self::LegacyRequired,
_ => Self::UnknownValue(field_presence::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for FieldPresence {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Unknown => serializer.serialize_i32(0),
Self::Explicit => serializer.serialize_i32(1),
Self::Implicit => serializer.serialize_i32(2),
Self::LegacyRequired => serializer.serialize_i32(3),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for FieldPresence {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<FieldPresence>::new(
".google.protobuf.FeatureSet.FieldPresence",
))
}
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum EnumType {
Unknown,
Open,
Closed,
UnknownValue(enum_type::UnknownValue),
}
#[doc(hidden)]
pub mod enum_type {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl EnumType {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Unknown => std::option::Option::Some(0),
Self::Open => std::option::Option::Some(1),
Self::Closed => std::option::Option::Some(2),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Unknown => std::option::Option::Some("ENUM_TYPE_UNKNOWN"),
Self::Open => std::option::Option::Some("OPEN"),
Self::Closed => std::option::Option::Some("CLOSED"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for EnumType {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for EnumType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for EnumType {
fn from(value: i32) -> Self {
match value {
0 => Self::Unknown,
1 => Self::Open,
2 => Self::Closed,
_ => Self::UnknownValue(enum_type::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for EnumType {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"ENUM_TYPE_UNKNOWN" => Self::Unknown,
"OPEN" => Self::Open,
"CLOSED" => Self::Closed,
_ => Self::UnknownValue(enum_type::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for EnumType {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Unknown => serializer.serialize_i32(0),
Self::Open => serializer.serialize_i32(1),
Self::Closed => serializer.serialize_i32(2),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for EnumType {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<EnumType>::new(
".google.protobuf.FeatureSet.EnumType",
))
}
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum RepeatedFieldEncoding {
Unknown,
Packed,
Expanded,
UnknownValue(repeated_field_encoding::UnknownValue),
}
#[doc(hidden)]
pub mod repeated_field_encoding {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl RepeatedFieldEncoding {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Unknown => std::option::Option::Some(0),
Self::Packed => std::option::Option::Some(1),
Self::Expanded => std::option::Option::Some(2),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Unknown => std::option::Option::Some("REPEATED_FIELD_ENCODING_UNKNOWN"),
Self::Packed => std::option::Option::Some("PACKED"),
Self::Expanded => std::option::Option::Some("EXPANDED"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for RepeatedFieldEncoding {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for RepeatedFieldEncoding {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for RepeatedFieldEncoding {
fn from(value: i32) -> Self {
match value {
0 => Self::Unknown,
1 => Self::Packed,
2 => Self::Expanded,
_ => Self::UnknownValue(repeated_field_encoding::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for RepeatedFieldEncoding {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"REPEATED_FIELD_ENCODING_UNKNOWN" => Self::Unknown,
"PACKED" => Self::Packed,
"EXPANDED" => Self::Expanded,
_ => Self::UnknownValue(repeated_field_encoding::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for RepeatedFieldEncoding {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Unknown => serializer.serialize_i32(0),
Self::Packed => serializer.serialize_i32(1),
Self::Expanded => serializer.serialize_i32(2),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for RepeatedFieldEncoding {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<RepeatedFieldEncoding>::new(
".google.protobuf.FeatureSet.RepeatedFieldEncoding",
))
}
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum Utf8Validation {
Unknown,
Verify,
None,
UnknownValue(utf_8_validation::UnknownValue),
}
#[doc(hidden)]
pub mod utf_8_validation {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl Utf8Validation {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Unknown => std::option::Option::Some(0),
Self::Verify => std::option::Option::Some(2),
Self::None => std::option::Option::Some(3),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Unknown => std::option::Option::Some("UTF8_VALIDATION_UNKNOWN"),
Self::Verify => std::option::Option::Some("VERIFY"),
Self::None => std::option::Option::Some("NONE"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for Utf8Validation {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for Utf8Validation {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for Utf8Validation {
fn from(value: i32) -> Self {
match value {
0 => Self::Unknown,
2 => Self::Verify,
3 => Self::None,
_ => Self::UnknownValue(utf_8_validation::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for Utf8Validation {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"UTF8_VALIDATION_UNKNOWN" => Self::Unknown,
"VERIFY" => Self::Verify,
"NONE" => Self::None,
_ => Self::UnknownValue(utf_8_validation::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for Utf8Validation {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Unknown => serializer.serialize_i32(0),
Self::Verify => serializer.serialize_i32(2),
Self::None => serializer.serialize_i32(3),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for Utf8Validation {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<Utf8Validation>::new(
".google.protobuf.FeatureSet.Utf8Validation",
))
}
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum MessageEncoding {
Unknown,
LengthPrefixed,
Delimited,
UnknownValue(message_encoding::UnknownValue),
}
#[doc(hidden)]
pub mod message_encoding {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl MessageEncoding {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Unknown => std::option::Option::Some(0),
Self::LengthPrefixed => std::option::Option::Some(1),
Self::Delimited => std::option::Option::Some(2),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Unknown => std::option::Option::Some("MESSAGE_ENCODING_UNKNOWN"),
Self::LengthPrefixed => std::option::Option::Some("LENGTH_PREFIXED"),
Self::Delimited => std::option::Option::Some("DELIMITED"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for MessageEncoding {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for MessageEncoding {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for MessageEncoding {
fn from(value: i32) -> Self {
match value {
0 => Self::Unknown,
1 => Self::LengthPrefixed,
2 => Self::Delimited,
_ => Self::UnknownValue(message_encoding::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for MessageEncoding {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"MESSAGE_ENCODING_UNKNOWN" => Self::Unknown,
"LENGTH_PREFIXED" => Self::LengthPrefixed,
"DELIMITED" => Self::Delimited,
_ => Self::UnknownValue(message_encoding::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for MessageEncoding {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Unknown => serializer.serialize_i32(0),
Self::LengthPrefixed => serializer.serialize_i32(1),
Self::Delimited => serializer.serialize_i32(2),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for MessageEncoding {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<MessageEncoding>::new(
".google.protobuf.FeatureSet.MessageEncoding",
))
}
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum JsonFormat {
Unknown,
Allow,
LegacyBestEffort,
UnknownValue(json_format::UnknownValue),
}
#[doc(hidden)]
pub mod json_format {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl JsonFormat {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Unknown => std::option::Option::Some(0),
Self::Allow => std::option::Option::Some(1),
Self::LegacyBestEffort => std::option::Option::Some(2),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Unknown => std::option::Option::Some("JSON_FORMAT_UNKNOWN"),
Self::Allow => std::option::Option::Some("ALLOW"),
Self::LegacyBestEffort => std::option::Option::Some("LEGACY_BEST_EFFORT"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for JsonFormat {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for JsonFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for JsonFormat {
fn from(value: i32) -> Self {
match value {
0 => Self::Unknown,
1 => Self::Allow,
2 => Self::LegacyBestEffort,
_ => Self::UnknownValue(json_format::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for JsonFormat {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"JSON_FORMAT_UNKNOWN" => Self::Unknown,
"ALLOW" => Self::Allow,
"LEGACY_BEST_EFFORT" => Self::LegacyBestEffort,
_ => Self::UnknownValue(json_format::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for JsonFormat {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Unknown => serializer.serialize_i32(0),
Self::Allow => serializer.serialize_i32(1),
Self::LegacyBestEffort => serializer.serialize_i32(2),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for JsonFormat {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<JsonFormat>::new(
".google.protobuf.FeatureSet.JsonFormat",
))
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct FeatureSetDefaults {
pub defaults: std::vec::Vec<crate::feature_set_defaults::FeatureSetEditionDefault>,
pub minimum_edition: crate::Edition,
pub maximum_edition: crate::Edition,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl FeatureSetDefaults {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_defaults<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::feature_set_defaults::FeatureSetEditionDefault>,
{
use std::iter::Iterator;
self.defaults = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_minimum_edition<T: std::convert::Into<crate::Edition>>(mut self, v: T) -> Self {
self.minimum_edition = v.into();
self
}
pub fn set_maximum_edition<T: std::convert::Into<crate::Edition>>(mut self, v: T) -> Self {
self.maximum_edition = v.into();
self
}
}
impl wkt::message::Message for FeatureSetDefaults {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.FeatureSetDefaults"
}
}
pub mod feature_set_defaults {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct FeatureSetEditionDefault {
pub edition: crate::Edition,
pub overridable_features: std::option::Option<crate::FeatureSet>,
pub fixed_features: std::option::Option<crate::FeatureSet>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl FeatureSetEditionDefault {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_edition<T: std::convert::Into<crate::Edition>>(mut self, v: T) -> Self {
self.edition = v.into();
self
}
pub fn set_overridable_features<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.overridable_features = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_overridable_features<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.overridable_features = v.map(|x| x.into());
self
}
pub fn set_fixed_features<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.fixed_features = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_fixed_features<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::FeatureSet>,
{
self.fixed_features = v.map(|x| x.into());
self
}
}
impl wkt::message::Message for FeatureSetEditionDefault {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault"
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SourceCodeInfo {
pub location: std::vec::Vec<crate::source_code_info::Location>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl SourceCodeInfo {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_location<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::source_code_info::Location>,
{
use std::iter::Iterator;
self.location = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for SourceCodeInfo {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.SourceCodeInfo"
}
}
pub mod source_code_info {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Location {
pub path: std::vec::Vec<i32>,
pub span: std::vec::Vec<i32>,
pub leading_comments: std::string::String,
pub trailing_comments: std::string::String,
pub leading_detached_comments: std::vec::Vec<std::string::String>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl Location {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_path<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<i32>,
{
use std::iter::Iterator;
self.path = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_span<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<i32>,
{
use std::iter::Iterator;
self.span = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_leading_comments<T: std::convert::Into<std::string::String>>(
mut self,
v: T,
) -> Self {
self.leading_comments = v.into();
self
}
pub fn set_trailing_comments<T: std::convert::Into<std::string::String>>(
mut self,
v: T,
) -> Self {
self.trailing_comments = v.into();
self
}
pub fn set_leading_detached_comments<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<std::string::String>,
{
use std::iter::Iterator;
self.leading_detached_comments = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for Location {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.SourceCodeInfo.Location"
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GeneratedCodeInfo {
pub annotation: std::vec::Vec<crate::generated_code_info::Annotation>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl GeneratedCodeInfo {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_annotation<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::generated_code_info::Annotation>,
{
use std::iter::Iterator;
self.annotation = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for GeneratedCodeInfo {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.GeneratedCodeInfo"
}
}
pub mod generated_code_info {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Annotation {
pub path: std::vec::Vec<i32>,
pub source_file: std::string::String,
pub begin: i32,
pub end: i32,
pub semantic: crate::generated_code_info::annotation::Semantic,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl Annotation {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_path<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<i32>,
{
use std::iter::Iterator;
self.path = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_source_file<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.source_file = v.into();
self
}
pub fn set_begin<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.begin = v.into();
self
}
pub fn set_end<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.end = v.into();
self
}
pub fn set_semantic<
T: std::convert::Into<crate::generated_code_info::annotation::Semantic>,
>(
mut self,
v: T,
) -> Self {
self.semantic = v.into();
self
}
}
impl wkt::message::Message for Annotation {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.GeneratedCodeInfo.Annotation"
}
}
pub mod annotation {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum Semantic {
None,
Set,
Alias,
UnknownValue(semantic::UnknownValue),
}
#[doc(hidden)]
pub mod semantic {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl Semantic {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::None => std::option::Option::Some(0),
Self::Set => std::option::Option::Some(1),
Self::Alias => std::option::Option::Some(2),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::None => std::option::Option::Some("NONE"),
Self::Set => std::option::Option::Some("SET"),
Self::Alias => std::option::Option::Some("ALIAS"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for Semantic {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for Semantic {
fn fmt(
&self,
f: &mut std::fmt::Formatter<'_>,
) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for Semantic {
fn from(value: i32) -> Self {
match value {
0 => Self::None,
1 => Self::Set,
2 => Self::Alias,
_ => Self::UnknownValue(semantic::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for Semantic {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"NONE" => Self::None,
"SET" => Self::Set,
"ALIAS" => Self::Alias,
_ => Self::UnknownValue(semantic::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for Semantic {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::None => serializer.serialize_i32(0),
Self::Set => serializer.serialize_i32(1),
Self::Alias => serializer.serialize_i32(2),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for Semantic {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<Semantic>::new(
".google.protobuf.GeneratedCodeInfo.Annotation.Semantic",
))
}
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SourceContext {
pub file_name: std::string::String,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl SourceContext {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_file_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.file_name = v.into();
self
}
}
impl wkt::message::Message for SourceContext {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.SourceContext"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Type {
pub name: std::string::String,
pub fields: std::vec::Vec<crate::Field>,
pub oneofs: std::vec::Vec<std::string::String>,
pub options: std::vec::Vec<crate::Option>,
pub source_context: std::option::Option<crate::SourceContext>,
pub syntax: crate::Syntax,
pub edition: std::string::String,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl Type {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_fields<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::Field>,
{
use std::iter::Iterator;
self.fields = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_oneofs<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<std::string::String>,
{
use std::iter::Iterator;
self.oneofs = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_options<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::Option>,
{
use std::iter::Iterator;
self.options = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_source_context<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::SourceContext>,
{
self.source_context = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_source_context<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::SourceContext>,
{
self.source_context = v.map(|x| x.into());
self
}
pub fn set_syntax<T: std::convert::Into<crate::Syntax>>(mut self, v: T) -> Self {
self.syntax = v.into();
self
}
pub fn set_edition<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.edition = v.into();
self
}
}
impl wkt::message::Message for Type {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.Type"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Field {
pub kind: crate::field::Kind,
pub cardinality: crate::field::Cardinality,
pub number: i32,
pub name: std::string::String,
pub type_url: std::string::String,
pub oneof_index: i32,
pub packed: bool,
pub options: std::vec::Vec<crate::Option>,
pub json_name: std::string::String,
pub default_value: std::string::String,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl Field {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_kind<T: std::convert::Into<crate::field::Kind>>(mut self, v: T) -> Self {
self.kind = v.into();
self
}
pub fn set_cardinality<T: std::convert::Into<crate::field::Cardinality>>(
mut self,
v: T,
) -> Self {
self.cardinality = v.into();
self
}
pub fn set_number<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.number = v.into();
self
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_type_url<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.type_url = v.into();
self
}
pub fn set_oneof_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.oneof_index = v.into();
self
}
pub fn set_packed<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.packed = v.into();
self
}
pub fn set_options<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::Option>,
{
use std::iter::Iterator;
self.options = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_json_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.json_name = v.into();
self
}
pub fn set_default_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.default_value = v.into();
self
}
}
impl wkt::message::Message for Field {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.Field"
}
}
pub mod field {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum Kind {
TypeUnknown,
TypeDouble,
TypeFloat,
TypeInt64,
TypeUint64,
TypeInt32,
TypeFixed64,
TypeFixed32,
TypeBool,
TypeString,
TypeGroup,
TypeMessage,
TypeBytes,
TypeUint32,
TypeEnum,
TypeSfixed32,
TypeSfixed64,
TypeSint32,
TypeSint64,
UnknownValue(kind::UnknownValue),
}
#[doc(hidden)]
pub mod kind {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl Kind {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::TypeUnknown => std::option::Option::Some(0),
Self::TypeDouble => std::option::Option::Some(1),
Self::TypeFloat => std::option::Option::Some(2),
Self::TypeInt64 => std::option::Option::Some(3),
Self::TypeUint64 => std::option::Option::Some(4),
Self::TypeInt32 => std::option::Option::Some(5),
Self::TypeFixed64 => std::option::Option::Some(6),
Self::TypeFixed32 => std::option::Option::Some(7),
Self::TypeBool => std::option::Option::Some(8),
Self::TypeString => std::option::Option::Some(9),
Self::TypeGroup => std::option::Option::Some(10),
Self::TypeMessage => std::option::Option::Some(11),
Self::TypeBytes => std::option::Option::Some(12),
Self::TypeUint32 => std::option::Option::Some(13),
Self::TypeEnum => std::option::Option::Some(14),
Self::TypeSfixed32 => std::option::Option::Some(15),
Self::TypeSfixed64 => std::option::Option::Some(16),
Self::TypeSint32 => std::option::Option::Some(17),
Self::TypeSint64 => std::option::Option::Some(18),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::TypeUnknown => std::option::Option::Some("TYPE_UNKNOWN"),
Self::TypeDouble => std::option::Option::Some("TYPE_DOUBLE"),
Self::TypeFloat => std::option::Option::Some("TYPE_FLOAT"),
Self::TypeInt64 => std::option::Option::Some("TYPE_INT64"),
Self::TypeUint64 => std::option::Option::Some("TYPE_UINT64"),
Self::TypeInt32 => std::option::Option::Some("TYPE_INT32"),
Self::TypeFixed64 => std::option::Option::Some("TYPE_FIXED64"),
Self::TypeFixed32 => std::option::Option::Some("TYPE_FIXED32"),
Self::TypeBool => std::option::Option::Some("TYPE_BOOL"),
Self::TypeString => std::option::Option::Some("TYPE_STRING"),
Self::TypeGroup => std::option::Option::Some("TYPE_GROUP"),
Self::TypeMessage => std::option::Option::Some("TYPE_MESSAGE"),
Self::TypeBytes => std::option::Option::Some("TYPE_BYTES"),
Self::TypeUint32 => std::option::Option::Some("TYPE_UINT32"),
Self::TypeEnum => std::option::Option::Some("TYPE_ENUM"),
Self::TypeSfixed32 => std::option::Option::Some("TYPE_SFIXED32"),
Self::TypeSfixed64 => std::option::Option::Some("TYPE_SFIXED64"),
Self::TypeSint32 => std::option::Option::Some("TYPE_SINT32"),
Self::TypeSint64 => std::option::Option::Some("TYPE_SINT64"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for Kind {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for Kind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for Kind {
fn from(value: i32) -> Self {
match value {
0 => Self::TypeUnknown,
1 => Self::TypeDouble,
2 => Self::TypeFloat,
3 => Self::TypeInt64,
4 => Self::TypeUint64,
5 => Self::TypeInt32,
6 => Self::TypeFixed64,
7 => Self::TypeFixed32,
8 => Self::TypeBool,
9 => Self::TypeString,
10 => Self::TypeGroup,
11 => Self::TypeMessage,
12 => Self::TypeBytes,
13 => Self::TypeUint32,
14 => Self::TypeEnum,
15 => Self::TypeSfixed32,
16 => Self::TypeSfixed64,
17 => Self::TypeSint32,
18 => Self::TypeSint64,
_ => Self::UnknownValue(kind::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for Kind {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"TYPE_UNKNOWN" => Self::TypeUnknown,
"TYPE_DOUBLE" => Self::TypeDouble,
"TYPE_FLOAT" => Self::TypeFloat,
"TYPE_INT64" => Self::TypeInt64,
"TYPE_UINT64" => Self::TypeUint64,
"TYPE_INT32" => Self::TypeInt32,
"TYPE_FIXED64" => Self::TypeFixed64,
"TYPE_FIXED32" => Self::TypeFixed32,
"TYPE_BOOL" => Self::TypeBool,
"TYPE_STRING" => Self::TypeString,
"TYPE_GROUP" => Self::TypeGroup,
"TYPE_MESSAGE" => Self::TypeMessage,
"TYPE_BYTES" => Self::TypeBytes,
"TYPE_UINT32" => Self::TypeUint32,
"TYPE_ENUM" => Self::TypeEnum,
"TYPE_SFIXED32" => Self::TypeSfixed32,
"TYPE_SFIXED64" => Self::TypeSfixed64,
"TYPE_SINT32" => Self::TypeSint32,
"TYPE_SINT64" => Self::TypeSint64,
_ => Self::UnknownValue(kind::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for Kind {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::TypeUnknown => serializer.serialize_i32(0),
Self::TypeDouble => serializer.serialize_i32(1),
Self::TypeFloat => serializer.serialize_i32(2),
Self::TypeInt64 => serializer.serialize_i32(3),
Self::TypeUint64 => serializer.serialize_i32(4),
Self::TypeInt32 => serializer.serialize_i32(5),
Self::TypeFixed64 => serializer.serialize_i32(6),
Self::TypeFixed32 => serializer.serialize_i32(7),
Self::TypeBool => serializer.serialize_i32(8),
Self::TypeString => serializer.serialize_i32(9),
Self::TypeGroup => serializer.serialize_i32(10),
Self::TypeMessage => serializer.serialize_i32(11),
Self::TypeBytes => serializer.serialize_i32(12),
Self::TypeUint32 => serializer.serialize_i32(13),
Self::TypeEnum => serializer.serialize_i32(14),
Self::TypeSfixed32 => serializer.serialize_i32(15),
Self::TypeSfixed64 => serializer.serialize_i32(16),
Self::TypeSint32 => serializer.serialize_i32(17),
Self::TypeSint64 => serializer.serialize_i32(18),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for Kind {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<Kind>::new(
".google.protobuf.Field.Kind",
))
}
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum Cardinality {
Unknown,
Optional,
Required,
Repeated,
UnknownValue(cardinality::UnknownValue),
}
#[doc(hidden)]
pub mod cardinality {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl Cardinality {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Unknown => std::option::Option::Some(0),
Self::Optional => std::option::Option::Some(1),
Self::Required => std::option::Option::Some(2),
Self::Repeated => std::option::Option::Some(3),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Unknown => std::option::Option::Some("CARDINALITY_UNKNOWN"),
Self::Optional => std::option::Option::Some("CARDINALITY_OPTIONAL"),
Self::Required => std::option::Option::Some("CARDINALITY_REQUIRED"),
Self::Repeated => std::option::Option::Some("CARDINALITY_REPEATED"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for Cardinality {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for Cardinality {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for Cardinality {
fn from(value: i32) -> Self {
match value {
0 => Self::Unknown,
1 => Self::Optional,
2 => Self::Required,
3 => Self::Repeated,
_ => Self::UnknownValue(cardinality::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for Cardinality {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"CARDINALITY_UNKNOWN" => Self::Unknown,
"CARDINALITY_OPTIONAL" => Self::Optional,
"CARDINALITY_REQUIRED" => Self::Required,
"CARDINALITY_REPEATED" => Self::Repeated,
_ => Self::UnknownValue(cardinality::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for Cardinality {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Unknown => serializer.serialize_i32(0),
Self::Optional => serializer.serialize_i32(1),
Self::Required => serializer.serialize_i32(2),
Self::Repeated => serializer.serialize_i32(3),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for Cardinality {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<Cardinality>::new(
".google.protobuf.Field.Cardinality",
))
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Enum {
pub name: std::string::String,
pub enumvalue: std::vec::Vec<crate::EnumValue>,
pub options: std::vec::Vec<crate::Option>,
pub source_context: std::option::Option<crate::SourceContext>,
pub syntax: crate::Syntax,
pub edition: std::string::String,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl Enum {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_enumvalue<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::EnumValue>,
{
use std::iter::Iterator;
self.enumvalue = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_options<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::Option>,
{
use std::iter::Iterator;
self.options = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_source_context<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::SourceContext>,
{
self.source_context = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_source_context<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::SourceContext>,
{
self.source_context = v.map(|x| x.into());
self
}
pub fn set_syntax<T: std::convert::Into<crate::Syntax>>(mut self, v: T) -> Self {
self.syntax = v.into();
self
}
pub fn set_edition<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.edition = v.into();
self
}
}
impl wkt::message::Message for Enum {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.Enum"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct EnumValue {
pub name: std::string::String,
pub number: i32,
pub options: std::vec::Vec<crate::Option>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl EnumValue {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_number<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.number = v.into();
self
}
pub fn set_options<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::Option>,
{
use std::iter::Iterator;
self.options = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for EnumValue {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.EnumValue"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Option {
pub name: std::string::String,
pub value: std::option::Option<crate::Any>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl Option {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_value<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::Any>,
{
self.value = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_value<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::Any>,
{
self.value = v.map(|x| x.into());
self
}
}
impl wkt::message::Message for Option {
fn typename() -> &'static str {
"type.googleapis.com/google.protobuf.Option"
}
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum Edition {
Unknown,
Legacy,
Proto2,
Proto3,
Edition2023,
Edition2024,
Edition1TestOnly,
Edition2TestOnly,
Edition99997TestOnly,
Edition99998TestOnly,
Edition99999TestOnly,
Max,
UnknownValue(edition::UnknownValue),
}
#[doc(hidden)]
pub mod edition {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl Edition {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Unknown => std::option::Option::Some(0),
Self::Legacy => std::option::Option::Some(900),
Self::Proto2 => std::option::Option::Some(998),
Self::Proto3 => std::option::Option::Some(999),
Self::Edition2023 => std::option::Option::Some(1000),
Self::Edition2024 => std::option::Option::Some(1001),
Self::Edition1TestOnly => std::option::Option::Some(1),
Self::Edition2TestOnly => std::option::Option::Some(2),
Self::Edition99997TestOnly => std::option::Option::Some(99997),
Self::Edition99998TestOnly => std::option::Option::Some(99998),
Self::Edition99999TestOnly => std::option::Option::Some(99999),
Self::Max => std::option::Option::Some(2147483647),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Unknown => std::option::Option::Some("EDITION_UNKNOWN"),
Self::Legacy => std::option::Option::Some("EDITION_LEGACY"),
Self::Proto2 => std::option::Option::Some("EDITION_PROTO2"),
Self::Proto3 => std::option::Option::Some("EDITION_PROTO3"),
Self::Edition2023 => std::option::Option::Some("EDITION_2023"),
Self::Edition2024 => std::option::Option::Some("EDITION_2024"),
Self::Edition1TestOnly => std::option::Option::Some("EDITION_1_TEST_ONLY"),
Self::Edition2TestOnly => std::option::Option::Some("EDITION_2_TEST_ONLY"),
Self::Edition99997TestOnly => std::option::Option::Some("EDITION_99997_TEST_ONLY"),
Self::Edition99998TestOnly => std::option::Option::Some("EDITION_99998_TEST_ONLY"),
Self::Edition99999TestOnly => std::option::Option::Some("EDITION_99999_TEST_ONLY"),
Self::Max => std::option::Option::Some("EDITION_MAX"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for Edition {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for Edition {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for Edition {
fn from(value: i32) -> Self {
match value {
0 => Self::Unknown,
1 => Self::Edition1TestOnly,
2 => Self::Edition2TestOnly,
900 => Self::Legacy,
998 => Self::Proto2,
999 => Self::Proto3,
1000 => Self::Edition2023,
1001 => Self::Edition2024,
99997 => Self::Edition99997TestOnly,
99998 => Self::Edition99998TestOnly,
99999 => Self::Edition99999TestOnly,
2147483647 => Self::Max,
_ => Self::UnknownValue(edition::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for Edition {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"EDITION_UNKNOWN" => Self::Unknown,
"EDITION_LEGACY" => Self::Legacy,
"EDITION_PROTO2" => Self::Proto2,
"EDITION_PROTO3" => Self::Proto3,
"EDITION_2023" => Self::Edition2023,
"EDITION_2024" => Self::Edition2024,
"EDITION_1_TEST_ONLY" => Self::Edition1TestOnly,
"EDITION_2_TEST_ONLY" => Self::Edition2TestOnly,
"EDITION_99997_TEST_ONLY" => Self::Edition99997TestOnly,
"EDITION_99998_TEST_ONLY" => Self::Edition99998TestOnly,
"EDITION_99999_TEST_ONLY" => Self::Edition99999TestOnly,
"EDITION_MAX" => Self::Max,
_ => Self::UnknownValue(edition::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for Edition {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Unknown => serializer.serialize_i32(0),
Self::Legacy => serializer.serialize_i32(900),
Self::Proto2 => serializer.serialize_i32(998),
Self::Proto3 => serializer.serialize_i32(999),
Self::Edition2023 => serializer.serialize_i32(1000),
Self::Edition2024 => serializer.serialize_i32(1001),
Self::Edition1TestOnly => serializer.serialize_i32(1),
Self::Edition2TestOnly => serializer.serialize_i32(2),
Self::Edition99997TestOnly => serializer.serialize_i32(99997),
Self::Edition99998TestOnly => serializer.serialize_i32(99998),
Self::Edition99999TestOnly => serializer.serialize_i32(99999),
Self::Max => serializer.serialize_i32(2147483647),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for Edition {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<Edition>::new(
".google.protobuf.Edition",
))
}
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum Syntax {
Proto2,
Proto3,
Editions,
UnknownValue(syntax::UnknownValue),
}
#[doc(hidden)]
pub mod syntax {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl Syntax {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Proto2 => std::option::Option::Some(0),
Self::Proto3 => std::option::Option::Some(1),
Self::Editions => std::option::Option::Some(2),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Proto2 => std::option::Option::Some("SYNTAX_PROTO2"),
Self::Proto3 => std::option::Option::Some("SYNTAX_PROTO3"),
Self::Editions => std::option::Option::Some("SYNTAX_EDITIONS"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for Syntax {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for Syntax {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for Syntax {
fn from(value: i32) -> Self {
match value {
0 => Self::Proto2,
1 => Self::Proto3,
2 => Self::Editions,
_ => Self::UnknownValue(syntax::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for Syntax {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"SYNTAX_PROTO2" => Self::Proto2,
"SYNTAX_PROTO3" => Self::Proto3,
"SYNTAX_EDITIONS" => Self::Editions,
_ => Self::UnknownValue(syntax::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for Syntax {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Proto2 => serializer.serialize_i32(0),
Self::Proto3 => serializer.serialize_i32(1),
Self::Editions => serializer.serialize_i32(2),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for Syntax {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<Syntax>::new(
".google.protobuf.Syntax",
))
}
}