osmosis_std/types/cosmos/ics23/
v1.rs

1use osmosis_std_derive::CosmwasmExt;
2/// *
3/// ExistenceProof takes a key and a value and a set of steps to perform on it.
4/// The result of peforming all these steps will provide a "root hash", which can
5/// be compared to the value in a header.
6///
7/// Since it is computationally infeasible to produce a hash collission for any of the used
8/// cryptographic hash functions, if someone can provide a series of operations to transform
9/// a given key and value into a root hash that matches some trusted root, these key and values
10/// must be in the referenced merkle tree.
11///
12/// The only possible issue is maliablity in LeafOp, such as providing extra prefix data,
13/// which should be controlled by a spec. Eg. with lengthOp as NONE,
14/// prefix = FOO, key = BAR, value = CHOICE
15/// and
16/// prefix = F, key = OOBAR, value = CHOICE
17/// would produce the same value.
18///
19/// With LengthOp this is tricker but not impossible. Which is why the "leafPrefixEqual" field
20/// in the ProofSpec is valuable to prevent this mutability. And why all trees should
21/// length-prefix the data before hashing it.
22#[allow(clippy::derive_partial_eq_without_eq)]
23#[derive(
24    Clone,
25    PartialEq,
26    Eq,
27    ::prost::Message,
28    ::serde::Serialize,
29    ::serde::Deserialize,
30    ::schemars::JsonSchema,
31    CosmwasmExt,
32)]
33#[proto_message(type_url = "/cosmos.ics23.v1.ExistenceProof")]
34pub struct ExistenceProof {
35    #[prost(bytes = "vec", tag = "1")]
36    #[serde(
37        serialize_with = "crate::serde::as_base64_encoded_string::serialize",
38        deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
39    )]
40    pub key: ::prost::alloc::vec::Vec<u8>,
41    #[prost(bytes = "vec", tag = "2")]
42    #[serde(
43        serialize_with = "crate::serde::as_base64_encoded_string::serialize",
44        deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
45    )]
46    pub value: ::prost::alloc::vec::Vec<u8>,
47    #[prost(message, optional, tag = "3")]
48    pub leaf: ::core::option::Option<LeafOp>,
49    #[prost(message, repeated, tag = "4")]
50    pub path: ::prost::alloc::vec::Vec<InnerOp>,
51}
52///
53/// NonExistenceProof takes a proof of two neighbors, one left of the desired key,
54/// one right of the desired key. If both proofs are valid AND they are neighbors,
55/// then there is no valid proof for the given key.
56#[allow(clippy::derive_partial_eq_without_eq)]
57#[derive(
58    Clone,
59    PartialEq,
60    Eq,
61    ::prost::Message,
62    ::serde::Serialize,
63    ::serde::Deserialize,
64    ::schemars::JsonSchema,
65    CosmwasmExt,
66)]
67#[proto_message(type_url = "/cosmos.ics23.v1.NonExistenceProof")]
68pub struct NonExistenceProof {
69    /// TODO: remove this as unnecessary??? we prove a range
70    #[prost(bytes = "vec", tag = "1")]
71    #[serde(
72        serialize_with = "crate::serde::as_base64_encoded_string::serialize",
73        deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
74    )]
75    pub key: ::prost::alloc::vec::Vec<u8>,
76    #[prost(message, optional, tag = "2")]
77    pub left: ::core::option::Option<ExistenceProof>,
78    #[prost(message, optional, tag = "3")]
79    pub right: ::core::option::Option<ExistenceProof>,
80}
81///
82/// CommitmentProof is either an ExistenceProof or a NonExistenceProof, or a Batch of such messages
83#[allow(clippy::derive_partial_eq_without_eq)]
84#[derive(
85    Clone,
86    PartialEq,
87    Eq,
88    ::prost::Message,
89    ::serde::Serialize,
90    ::serde::Deserialize,
91    ::schemars::JsonSchema,
92    CosmwasmExt,
93)]
94#[proto_message(type_url = "/cosmos.ics23.v1.CommitmentProof")]
95pub struct CommitmentProof {
96    #[prost(oneof = "commitment_proof::Proof", tags = "1, 2, 3, 4")]
97    pub proof: ::core::option::Option<commitment_proof::Proof>,
98}
99/// Nested message and enum types in `CommitmentProof`.
100pub mod commitment_proof {
101    use osmosis_std_derive::CosmwasmExt;
102    #[allow(clippy::derive_partial_eq_without_eq)]
103    #[derive(
104        Clone,
105        PartialEq,
106        Eq,
107        ::prost::Oneof,
108        ::serde::Serialize,
109        ::serde::Deserialize,
110        ::schemars::JsonSchema,
111    )]
112    pub enum Proof {
113        #[prost(message, tag = "1")]
114        Exist(super::ExistenceProof),
115        #[prost(message, tag = "2")]
116        Nonexist(super::NonExistenceProof),
117        #[prost(message, tag = "3")]
118        Batch(super::BatchProof),
119        #[prost(message, tag = "4")]
120        Compressed(super::CompressedBatchProof),
121    }
122}
123/// *
124/// LeafOp represents the raw key-value data we wish to prove, and
125/// must be flexible to represent the internal transformation from
126/// the original key-value pairs into the basis hash, for many existing
127/// merkle trees.
128///
129/// key and value are passed in. So that the signature of this operation is:
130/// leafOp(key, value) -> output
131///
132/// To process this, first prehash the keys and values if needed (ANY means no hash in this case):
133/// hkey = prehashKey(key)
134/// hvalue = prehashValue(value)
135///
136/// Then combine the bytes, and hash it
137/// output = hash(prefix || length(hkey) || hkey || length(hvalue) || hvalue)
138#[allow(clippy::derive_partial_eq_without_eq)]
139#[derive(
140    Clone,
141    PartialEq,
142    Eq,
143    ::prost::Message,
144    ::serde::Serialize,
145    ::serde::Deserialize,
146    ::schemars::JsonSchema,
147    CosmwasmExt,
148)]
149#[proto_message(type_url = "/cosmos.ics23.v1.LeafOp")]
150pub struct LeafOp {
151    #[prost(enumeration = "HashOp", tag = "1")]
152    #[serde(
153        serialize_with = "crate::serde::as_str::serialize",
154        deserialize_with = "crate::serde::as_str::deserialize"
155    )]
156    pub hash: i32,
157    #[prost(enumeration = "HashOp", tag = "2")]
158    #[serde(
159        serialize_with = "crate::serde::as_str::serialize",
160        deserialize_with = "crate::serde::as_str::deserialize"
161    )]
162    pub prehash_key: i32,
163    #[prost(enumeration = "HashOp", tag = "3")]
164    #[serde(
165        serialize_with = "crate::serde::as_str::serialize",
166        deserialize_with = "crate::serde::as_str::deserialize"
167    )]
168    pub prehash_value: i32,
169    #[prost(enumeration = "LengthOp", tag = "4")]
170    #[serde(
171        serialize_with = "crate::serde::as_str::serialize",
172        deserialize_with = "crate::serde::as_str::deserialize"
173    )]
174    pub length: i32,
175    /// prefix is a fixed bytes that may optionally be included at the beginning to differentiate
176    /// a leaf node from an inner node.
177    #[prost(bytes = "vec", tag = "5")]
178    #[serde(
179        serialize_with = "crate::serde::as_base64_encoded_string::serialize",
180        deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
181    )]
182    pub prefix: ::prost::alloc::vec::Vec<u8>,
183}
184/// *
185/// InnerOp represents a merkle-proof step that is not a leaf.
186/// It represents concatenating two children and hashing them to provide the next result.
187///
188/// The result of the previous step is passed in, so the signature of this op is:
189/// innerOp(child) -> output
190///
191/// The result of applying InnerOp should be:
192/// output = op.hash(op.prefix || child || op.suffix)
193///
194/// where the || operator is concatenation of binary data,
195/// and child is the result of hashing all the tree below this step.
196///
197/// Any special data, like prepending child with the length, or prepending the entire operation with
198/// some value to differentiate from leaf nodes, should be included in prefix and suffix.
199/// If either of prefix or suffix is empty, we just treat it as an empty string
200#[allow(clippy::derive_partial_eq_without_eq)]
201#[derive(
202    Clone,
203    PartialEq,
204    Eq,
205    ::prost::Message,
206    ::serde::Serialize,
207    ::serde::Deserialize,
208    ::schemars::JsonSchema,
209    CosmwasmExt,
210)]
211#[proto_message(type_url = "/cosmos.ics23.v1.InnerOp")]
212pub struct InnerOp {
213    #[prost(enumeration = "HashOp", tag = "1")]
214    #[serde(
215        serialize_with = "crate::serde::as_str::serialize",
216        deserialize_with = "crate::serde::as_str::deserialize"
217    )]
218    pub hash: i32,
219    #[prost(bytes = "vec", tag = "2")]
220    #[serde(
221        serialize_with = "crate::serde::as_base64_encoded_string::serialize",
222        deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
223    )]
224    pub prefix: ::prost::alloc::vec::Vec<u8>,
225    #[prost(bytes = "vec", tag = "3")]
226    #[serde(
227        serialize_with = "crate::serde::as_base64_encoded_string::serialize",
228        deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
229    )]
230    pub suffix: ::prost::alloc::vec::Vec<u8>,
231}
232/// *
233/// ProofSpec defines what the expected parameters are for a given proof type.
234/// This can be stored in the client and used to validate any incoming proofs.
235///
236/// verify(ProofSpec, Proof) -> Proof | Error
237///
238/// As demonstrated in tests, if we don't fix the algorithm used to calculate the
239/// LeafHash for a given tree, there are many possible key-value pairs that can
240/// generate a given hash (by interpretting the preimage differently).
241/// We need this for proper security, requires client knows a priori what
242/// tree format server uses. But not in code, rather a configuration object.
243#[allow(clippy::derive_partial_eq_without_eq)]
244#[derive(
245    Clone,
246    PartialEq,
247    Eq,
248    ::prost::Message,
249    ::serde::Serialize,
250    ::serde::Deserialize,
251    ::schemars::JsonSchema,
252    CosmwasmExt,
253)]
254#[proto_message(type_url = "/cosmos.ics23.v1.ProofSpec")]
255pub struct ProofSpec {
256    /// any field in the ExistenceProof must be the same as in this spec.
257    /// except Prefix, which is just the first bytes of prefix (spec can be longer)
258    #[prost(message, optional, tag = "1")]
259    pub leaf_spec: ::core::option::Option<LeafOp>,
260    #[prost(message, optional, tag = "2")]
261    pub inner_spec: ::core::option::Option<InnerSpec>,
262    /// max_depth (if > 0) is the maximum number of InnerOps allowed (mainly for fixed-depth tries)
263    #[prost(int32, tag = "3")]
264    #[serde(
265        serialize_with = "crate::serde::as_str::serialize",
266        deserialize_with = "crate::serde::as_str::deserialize"
267    )]
268    pub max_depth: i32,
269    /// min_depth (if > 0) is the minimum number of InnerOps allowed (mainly for fixed-depth tries)
270    #[prost(int32, tag = "4")]
271    #[serde(
272        serialize_with = "crate::serde::as_str::serialize",
273        deserialize_with = "crate::serde::as_str::deserialize"
274    )]
275    pub min_depth: i32,
276    /// prehash_key_before_comparison is a flag that indicates whether to use the
277    /// prehash_key specified by LeafOp to compare lexical ordering of keys for
278    /// non-existence proofs.
279    #[prost(bool, tag = "5")]
280    pub prehash_key_before_comparison: bool,
281}
282///
283/// InnerSpec contains all store-specific structure info to determine if two proofs from a
284/// given store are neighbors.
285///
286/// This enables:
287///
288/// isLeftMost(spec: InnerSpec, op: InnerOp)
289/// isRightMost(spec: InnerSpec, op: InnerOp)
290/// isLeftNeighbor(spec: InnerSpec, left: InnerOp, right: InnerOp)
291#[allow(clippy::derive_partial_eq_without_eq)]
292#[derive(
293    Clone,
294    PartialEq,
295    Eq,
296    ::prost::Message,
297    ::serde::Serialize,
298    ::serde::Deserialize,
299    ::schemars::JsonSchema,
300    CosmwasmExt,
301)]
302#[proto_message(type_url = "/cosmos.ics23.v1.InnerSpec")]
303pub struct InnerSpec {
304    /// Child order is the ordering of the children node, must count from 0
305    /// iavl tree is [0, 1] (left then right)
306    /// merk is [0, 2, 1] (left, right, here)
307    #[prost(int32, repeated, tag = "1")]
308    #[serde(
309        serialize_with = "crate::serde::as_str_vec::serialize",
310        deserialize_with = "crate::serde::as_str_vec::deserialize"
311    )]
312    pub child_order: ::prost::alloc::vec::Vec<i32>,
313    #[prost(int32, tag = "2")]
314    #[serde(
315        serialize_with = "crate::serde::as_str::serialize",
316        deserialize_with = "crate::serde::as_str::deserialize"
317    )]
318    pub child_size: i32,
319    #[prost(int32, tag = "3")]
320    #[serde(
321        serialize_with = "crate::serde::as_str::serialize",
322        deserialize_with = "crate::serde::as_str::deserialize"
323    )]
324    pub min_prefix_length: i32,
325    #[prost(int32, tag = "4")]
326    #[serde(
327        serialize_with = "crate::serde::as_str::serialize",
328        deserialize_with = "crate::serde::as_str::deserialize"
329    )]
330    pub max_prefix_length: i32,
331    /// empty child is the prehash image that is used when one child is nil (eg. 20 bytes of 0)
332    #[prost(bytes = "vec", tag = "5")]
333    #[serde(
334        serialize_with = "crate::serde::as_base64_encoded_string::serialize",
335        deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
336    )]
337    pub empty_child: ::prost::alloc::vec::Vec<u8>,
338    /// hash is the algorithm that must be used for each InnerOp
339    #[prost(enumeration = "HashOp", tag = "6")]
340    #[serde(
341        serialize_with = "crate::serde::as_str::serialize",
342        deserialize_with = "crate::serde::as_str::deserialize"
343    )]
344    pub hash: i32,
345}
346///
347/// BatchProof is a group of multiple proof types than can be compressed
348#[allow(clippy::derive_partial_eq_without_eq)]
349#[derive(
350    Clone,
351    PartialEq,
352    Eq,
353    ::prost::Message,
354    ::serde::Serialize,
355    ::serde::Deserialize,
356    ::schemars::JsonSchema,
357    CosmwasmExt,
358)]
359#[proto_message(type_url = "/cosmos.ics23.v1.BatchProof")]
360pub struct BatchProof {
361    #[prost(message, repeated, tag = "1")]
362    pub entries: ::prost::alloc::vec::Vec<BatchEntry>,
363}
364/// Use BatchEntry not CommitmentProof, to avoid recursion
365#[allow(clippy::derive_partial_eq_without_eq)]
366#[derive(
367    Clone,
368    PartialEq,
369    Eq,
370    ::prost::Message,
371    ::serde::Serialize,
372    ::serde::Deserialize,
373    ::schemars::JsonSchema,
374    CosmwasmExt,
375)]
376#[proto_message(type_url = "/cosmos.ics23.v1.BatchEntry")]
377pub struct BatchEntry {
378    #[prost(oneof = "batch_entry::Proof", tags = "1, 2")]
379    pub proof: ::core::option::Option<batch_entry::Proof>,
380}
381/// Nested message and enum types in `BatchEntry`.
382pub mod batch_entry {
383    use osmosis_std_derive::CosmwasmExt;
384    #[allow(clippy::derive_partial_eq_without_eq)]
385    #[derive(
386        Clone,
387        PartialEq,
388        Eq,
389        ::prost::Oneof,
390        ::serde::Serialize,
391        ::serde::Deserialize,
392        ::schemars::JsonSchema,
393    )]
394    pub enum Proof {
395        #[prost(message, tag = "1")]
396        Exist(super::ExistenceProof),
397        #[prost(message, tag = "2")]
398        Nonexist(super::NonExistenceProof),
399    }
400}
401#[allow(clippy::derive_partial_eq_without_eq)]
402#[derive(
403    Clone,
404    PartialEq,
405    Eq,
406    ::prost::Message,
407    ::serde::Serialize,
408    ::serde::Deserialize,
409    ::schemars::JsonSchema,
410    CosmwasmExt,
411)]
412#[proto_message(type_url = "/cosmos.ics23.v1.CompressedBatchProof")]
413pub struct CompressedBatchProof {
414    #[prost(message, repeated, tag = "1")]
415    pub entries: ::prost::alloc::vec::Vec<CompressedBatchEntry>,
416    #[prost(message, repeated, tag = "2")]
417    pub lookup_inners: ::prost::alloc::vec::Vec<InnerOp>,
418}
419/// Use BatchEntry not CommitmentProof, to avoid recursion
420#[allow(clippy::derive_partial_eq_without_eq)]
421#[derive(
422    Clone,
423    PartialEq,
424    Eq,
425    ::prost::Message,
426    ::serde::Serialize,
427    ::serde::Deserialize,
428    ::schemars::JsonSchema,
429    CosmwasmExt,
430)]
431#[proto_message(type_url = "/cosmos.ics23.v1.CompressedBatchEntry")]
432pub struct CompressedBatchEntry {
433    #[prost(oneof = "compressed_batch_entry::Proof", tags = "1, 2")]
434    pub proof: ::core::option::Option<compressed_batch_entry::Proof>,
435}
436/// Nested message and enum types in `CompressedBatchEntry`.
437pub mod compressed_batch_entry {
438    use osmosis_std_derive::CosmwasmExt;
439    #[allow(clippy::derive_partial_eq_without_eq)]
440    #[derive(
441        Clone,
442        PartialEq,
443        Eq,
444        ::prost::Oneof,
445        ::serde::Serialize,
446        ::serde::Deserialize,
447        ::schemars::JsonSchema,
448    )]
449    pub enum Proof {
450        #[prost(message, tag = "1")]
451        Exist(super::CompressedExistenceProof),
452        #[prost(message, tag = "2")]
453        Nonexist(super::CompressedNonExistenceProof),
454    }
455}
456#[allow(clippy::derive_partial_eq_without_eq)]
457#[derive(
458    Clone,
459    PartialEq,
460    Eq,
461    ::prost::Message,
462    ::serde::Serialize,
463    ::serde::Deserialize,
464    ::schemars::JsonSchema,
465    CosmwasmExt,
466)]
467#[proto_message(type_url = "/cosmos.ics23.v1.CompressedExistenceProof")]
468pub struct CompressedExistenceProof {
469    #[prost(bytes = "vec", tag = "1")]
470    #[serde(
471        serialize_with = "crate::serde::as_base64_encoded_string::serialize",
472        deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
473    )]
474    pub key: ::prost::alloc::vec::Vec<u8>,
475    #[prost(bytes = "vec", tag = "2")]
476    #[serde(
477        serialize_with = "crate::serde::as_base64_encoded_string::serialize",
478        deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
479    )]
480    pub value: ::prost::alloc::vec::Vec<u8>,
481    #[prost(message, optional, tag = "3")]
482    pub leaf: ::core::option::Option<LeafOp>,
483    /// these are indexes into the lookup_inners table in CompressedBatchProof
484    #[prost(int32, repeated, tag = "4")]
485    #[serde(
486        serialize_with = "crate::serde::as_str_vec::serialize",
487        deserialize_with = "crate::serde::as_str_vec::deserialize"
488    )]
489    pub path: ::prost::alloc::vec::Vec<i32>,
490}
491#[allow(clippy::derive_partial_eq_without_eq)]
492#[derive(
493    Clone,
494    PartialEq,
495    Eq,
496    ::prost::Message,
497    ::serde::Serialize,
498    ::serde::Deserialize,
499    ::schemars::JsonSchema,
500    CosmwasmExt,
501)]
502#[proto_message(type_url = "/cosmos.ics23.v1.CompressedNonExistenceProof")]
503pub struct CompressedNonExistenceProof {
504    /// TODO: remove this as unnecessary??? we prove a range
505    #[prost(bytes = "vec", tag = "1")]
506    #[serde(
507        serialize_with = "crate::serde::as_base64_encoded_string::serialize",
508        deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
509    )]
510    pub key: ::prost::alloc::vec::Vec<u8>,
511    #[prost(message, optional, tag = "2")]
512    pub left: ::core::option::Option<CompressedExistenceProof>,
513    #[prost(message, optional, tag = "3")]
514    pub right: ::core::option::Option<CompressedExistenceProof>,
515}
516#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
517#[repr(i32)]
518#[derive(::serde::Serialize, ::serde::Deserialize, ::schemars::JsonSchema)]
519pub enum HashOp {
520    /// NO_HASH is the default if no data passed. Note this is an illegal argument some places.
521    NoHash = 0,
522    Sha256 = 1,
523    Sha512 = 2,
524    Keccak = 3,
525    Ripemd160 = 4,
526    /// ripemd160(sha256(x))
527    Bitcoin = 5,
528    Sha512256 = 6,
529}
530impl HashOp {
531    /// String value of the enum field names used in the ProtoBuf definition.
532    ///
533    /// The values are not transformed in any way and thus are considered stable
534    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
535    pub fn as_str_name(&self) -> &'static str {
536        match self {
537            HashOp::NoHash => "NO_HASH",
538            HashOp::Sha256 => "SHA256",
539            HashOp::Sha512 => "SHA512",
540            HashOp::Keccak => "KECCAK",
541            HashOp::Ripemd160 => "RIPEMD160",
542            HashOp::Bitcoin => "BITCOIN",
543            HashOp::Sha512256 => "SHA512_256",
544        }
545    }
546    /// Creates an enum from field names used in the ProtoBuf definition.
547    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
548        match value {
549            "NO_HASH" => Some(Self::NoHash),
550            "SHA256" => Some(Self::Sha256),
551            "SHA512" => Some(Self::Sha512),
552            "KECCAK" => Some(Self::Keccak),
553            "RIPEMD160" => Some(Self::Ripemd160),
554            "BITCOIN" => Some(Self::Bitcoin),
555            "SHA512_256" => Some(Self::Sha512256),
556            _ => None,
557        }
558    }
559}
560/// *
561/// LengthOp defines how to process the key and value of the LeafOp
562/// to include length information. After encoding the length with the given
563/// algorithm, the length will be prepended to the key and value bytes.
564/// (Each one with it's own encoded length)
565#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
566#[repr(i32)]
567#[derive(::serde::Serialize, ::serde::Deserialize, ::schemars::JsonSchema)]
568pub enum LengthOp {
569    /// NO_PREFIX don't include any length info
570    NoPrefix = 0,
571    /// VAR_PROTO uses protobuf (and go-amino) varint encoding of the length
572    VarProto = 1,
573    /// VAR_RLP uses rlp int encoding of the length
574    VarRlp = 2,
575    /// FIXED32_BIG uses big-endian encoding of the length as a 32 bit integer
576    Fixed32Big = 3,
577    /// FIXED32_LITTLE uses little-endian encoding of the length as a 32 bit integer
578    Fixed32Little = 4,
579    /// FIXED64_BIG uses big-endian encoding of the length as a 64 bit integer
580    Fixed64Big = 5,
581    /// FIXED64_LITTLE uses little-endian encoding of the length as a 64 bit integer
582    Fixed64Little = 6,
583    /// REQUIRE_32_BYTES is like NONE, but will fail if the input is not exactly 32 bytes (sha256 output)
584    Require32Bytes = 7,
585    /// REQUIRE_64_BYTES is like NONE, but will fail if the input is not exactly 64 bytes (sha512 output)
586    Require64Bytes = 8,
587}
588impl LengthOp {
589    /// String value of the enum field names used in the ProtoBuf definition.
590    ///
591    /// The values are not transformed in any way and thus are considered stable
592    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
593    pub fn as_str_name(&self) -> &'static str {
594        match self {
595            LengthOp::NoPrefix => "NO_PREFIX",
596            LengthOp::VarProto => "VAR_PROTO",
597            LengthOp::VarRlp => "VAR_RLP",
598            LengthOp::Fixed32Big => "FIXED32_BIG",
599            LengthOp::Fixed32Little => "FIXED32_LITTLE",
600            LengthOp::Fixed64Big => "FIXED64_BIG",
601            LengthOp::Fixed64Little => "FIXED64_LITTLE",
602            LengthOp::Require32Bytes => "REQUIRE_32_BYTES",
603            LengthOp::Require64Bytes => "REQUIRE_64_BYTES",
604        }
605    }
606    /// Creates an enum from field names used in the ProtoBuf definition.
607    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
608        match value {
609            "NO_PREFIX" => Some(Self::NoPrefix),
610            "VAR_PROTO" => Some(Self::VarProto),
611            "VAR_RLP" => Some(Self::VarRlp),
612            "FIXED32_BIG" => Some(Self::Fixed32Big),
613            "FIXED32_LITTLE" => Some(Self::Fixed32Little),
614            "FIXED64_BIG" => Some(Self::Fixed64Big),
615            "FIXED64_LITTLE" => Some(Self::Fixed64Little),
616            "REQUIRE_32_BYTES" => Some(Self::Require32Bytes),
617            "REQUIRE_64_BYTES" => Some(Self::Require64Bytes),
618            _ => None,
619        }
620    }
621}