@@ -253,6 +253,30 @@ pub mod field_descriptor_proto {
253253 Type :: Sint64 => "TYPE_SINT64" ,
254254 }
255255 }
256+ /// Creates an enum from field names used in the ProtoBuf definition.
257+ pub fn from_str_name ( value : & str ) -> :: core:: option:: Option < Self > {
258+ match value {
259+ "TYPE_DOUBLE" => Some ( Self :: Double ) ,
260+ "TYPE_FLOAT" => Some ( Self :: Float ) ,
261+ "TYPE_INT64" => Some ( Self :: Int64 ) ,
262+ "TYPE_UINT64" => Some ( Self :: Uint64 ) ,
263+ "TYPE_INT32" => Some ( Self :: Int32 ) ,
264+ "TYPE_FIXED64" => Some ( Self :: Fixed64 ) ,
265+ "TYPE_FIXED32" => Some ( Self :: Fixed32 ) ,
266+ "TYPE_BOOL" => Some ( Self :: Bool ) ,
267+ "TYPE_STRING" => Some ( Self :: String ) ,
268+ "TYPE_GROUP" => Some ( Self :: Group ) ,
269+ "TYPE_MESSAGE" => Some ( Self :: Message ) ,
270+ "TYPE_BYTES" => Some ( Self :: Bytes ) ,
271+ "TYPE_UINT32" => Some ( Self :: Uint32 ) ,
272+ "TYPE_ENUM" => Some ( Self :: Enum ) ,
273+ "TYPE_SFIXED32" => Some ( Self :: Sfixed32 ) ,
274+ "TYPE_SFIXED64" => Some ( Self :: Sfixed64 ) ,
275+ "TYPE_SINT32" => Some ( Self :: Sint32 ) ,
276+ "TYPE_SINT64" => Some ( Self :: Sint64 ) ,
277+ _ => None ,
278+ }
279+ }
256280 }
257281 #[ derive(
258282 Clone ,
@@ -284,6 +308,15 @@ pub mod field_descriptor_proto {
284308 Label :: Repeated => "LABEL_REPEATED" ,
285309 }
286310 }
311+ /// Creates an enum from field names used in the ProtoBuf definition.
312+ pub fn from_str_name ( value : & str ) -> :: core:: option:: Option < Self > {
313+ match value {
314+ "LABEL_OPTIONAL" => Some ( Self :: Optional ) ,
315+ "LABEL_REQUIRED" => Some ( Self :: Required ) ,
316+ "LABEL_REPEATED" => Some ( Self :: Repeated ) ,
317+ _ => None ,
318+ }
319+ }
287320 }
288321}
289322/// Describes a oneof.
@@ -561,6 +594,15 @@ pub mod file_options {
561594 OptimizeMode :: LiteRuntime => "LITE_RUNTIME" ,
562595 }
563596 }
597+ /// Creates an enum from field names used in the ProtoBuf definition.
598+ pub fn from_str_name ( value : & str ) -> :: core:: option:: Option < Self > {
599+ match value {
600+ "SPEED" => Some ( Self :: Speed ) ,
601+ "CODE_SIZE" => Some ( Self :: CodeSize ) ,
602+ "LITE_RUNTIME" => Some ( Self :: LiteRuntime ) ,
603+ _ => None ,
604+ }
605+ }
564606 }
565607}
566608#[ allow( clippy:: derive_partial_eq_without_eq) ]
@@ -737,6 +779,15 @@ pub mod field_options {
737779 CType :: StringPiece => "STRING_PIECE" ,
738780 }
739781 }
782+ /// Creates an enum from field names used in the ProtoBuf definition.
783+ pub fn from_str_name ( value : & str ) -> :: core:: option:: Option < Self > {
784+ match value {
785+ "STRING" => Some ( Self :: String ) ,
786+ "CORD" => Some ( Self :: Cord ) ,
787+ "STRING_PIECE" => Some ( Self :: StringPiece ) ,
788+ _ => None ,
789+ }
790+ }
740791 }
741792 #[ derive(
742793 Clone ,
@@ -770,6 +821,15 @@ pub mod field_options {
770821 JsType :: JsNumber => "JS_NUMBER" ,
771822 }
772823 }
824+ /// Creates an enum from field names used in the ProtoBuf definition.
825+ pub fn from_str_name ( value : & str ) -> :: core:: option:: Option < Self > {
826+ match value {
827+ "JS_NORMAL" => Some ( Self :: JsNormal ) ,
828+ "JS_STRING" => Some ( Self :: JsString ) ,
829+ "JS_NUMBER" => Some ( Self :: JsNumber ) ,
830+ _ => None ,
831+ }
832+ }
773833 }
774834}
775835#[ allow( clippy:: derive_partial_eq_without_eq) ]
@@ -878,6 +938,15 @@ pub mod method_options {
878938 IdempotencyLevel :: Idempotent => "IDEMPOTENT" ,
879939 }
880940 }
941+ /// Creates an enum from field names used in the ProtoBuf definition.
942+ pub fn from_str_name ( value : & str ) -> :: core:: option:: Option < Self > {
943+ match value {
944+ "IDEMPOTENCY_UNKNOWN" => Some ( Self :: IdempotencyUnknown ) ,
945+ "NO_SIDE_EFFECTS" => Some ( Self :: NoSideEffects ) ,
946+ "IDEMPOTENT" => Some ( Self :: Idempotent ) ,
947+ _ => None ,
948+ }
949+ }
881950 }
882951}
883952/// A message representing a option the parser does not recognize. This only
@@ -1384,6 +1453,31 @@ pub mod field {
13841453 Kind :: TypeSint64 => "TYPE_SINT64" ,
13851454 }
13861455 }
1456+ /// Creates an enum from field names used in the ProtoBuf definition.
1457+ pub fn from_str_name ( value : & str ) -> :: core:: option:: Option < Self > {
1458+ match value {
1459+ "TYPE_UNKNOWN" => Some ( Self :: TypeUnknown ) ,
1460+ "TYPE_DOUBLE" => Some ( Self :: TypeDouble ) ,
1461+ "TYPE_FLOAT" => Some ( Self :: TypeFloat ) ,
1462+ "TYPE_INT64" => Some ( Self :: TypeInt64 ) ,
1463+ "TYPE_UINT64" => Some ( Self :: TypeUint64 ) ,
1464+ "TYPE_INT32" => Some ( Self :: TypeInt32 ) ,
1465+ "TYPE_FIXED64" => Some ( Self :: TypeFixed64 ) ,
1466+ "TYPE_FIXED32" => Some ( Self :: TypeFixed32 ) ,
1467+ "TYPE_BOOL" => Some ( Self :: TypeBool ) ,
1468+ "TYPE_STRING" => Some ( Self :: TypeString ) ,
1469+ "TYPE_GROUP" => Some ( Self :: TypeGroup ) ,
1470+ "TYPE_MESSAGE" => Some ( Self :: TypeMessage ) ,
1471+ "TYPE_BYTES" => Some ( Self :: TypeBytes ) ,
1472+ "TYPE_UINT32" => Some ( Self :: TypeUint32 ) ,
1473+ "TYPE_ENUM" => Some ( Self :: TypeEnum ) ,
1474+ "TYPE_SFIXED32" => Some ( Self :: TypeSfixed32 ) ,
1475+ "TYPE_SFIXED64" => Some ( Self :: TypeSfixed64 ) ,
1476+ "TYPE_SINT32" => Some ( Self :: TypeSint32 ) ,
1477+ "TYPE_SINT64" => Some ( Self :: TypeSint64 ) ,
1478+ _ => None ,
1479+ }
1480+ }
13871481 }
13881482 /// Whether a field is optional, required, or repeated.
13891483 #[ derive(
@@ -1421,6 +1515,16 @@ pub mod field {
14211515 Cardinality :: Repeated => "CARDINALITY_REPEATED" ,
14221516 }
14231517 }
1518+ /// Creates an enum from field names used in the ProtoBuf definition.
1519+ pub fn from_str_name ( value : & str ) -> :: core:: option:: Option < Self > {
1520+ match value {
1521+ "CARDINALITY_UNKNOWN" => Some ( Self :: Unknown ) ,
1522+ "CARDINALITY_OPTIONAL" => Some ( Self :: Optional ) ,
1523+ "CARDINALITY_REQUIRED" => Some ( Self :: Required ) ,
1524+ "CARDINALITY_REPEATED" => Some ( Self :: Repeated ) ,
1525+ _ => None ,
1526+ }
1527+ }
14241528 }
14251529}
14261530/// Enum type definition.
@@ -1495,6 +1599,14 @@ impl Syntax {
14951599 Syntax :: Proto3 => "SYNTAX_PROTO3" ,
14961600 }
14971601 }
1602+ /// Creates an enum from field names used in the ProtoBuf definition.
1603+ pub fn from_str_name ( value : & str ) -> :: core:: option:: Option < Self > {
1604+ match value {
1605+ "SYNTAX_PROTO2" => Some ( Self :: Proto2 ) ,
1606+ "SYNTAX_PROTO3" => Some ( Self :: Proto3 ) ,
1607+ _ => None ,
1608+ }
1609+ }
14981610}
14991611/// Api is a light-weight descriptor for an API Interface.
15001612///
@@ -2072,6 +2184,13 @@ impl NullValue {
20722184 NullValue :: NullValue => "NULL_VALUE" ,
20732185 }
20742186 }
2187+ /// Creates an enum from field names used in the ProtoBuf definition.
2188+ pub fn from_str_name ( value : & str ) -> :: core:: option:: Option < Self > {
2189+ match value {
2190+ "NULL_VALUE" => Some ( Self :: NullValue ) ,
2191+ _ => None ,
2192+ }
2193+ }
20752194}
20762195/// A Timestamp represents a point in time independent of any time zone or local
20772196/// calendar, encoded as a count of seconds and fractions of seconds at
0 commit comments