#[non_exhaustive]pub enum CodeGenError {
Show 25 variants
ViewJsonRuleMatchedNothing {
rule: String,
},
ZeroizeRuleMatchedNothing {
rule: String,
},
JsonPolicyTypeMatchedNothing {
rust_type: String,
},
JsonPolicyTypeNearMiss {
selected: String,
listed: String,
},
InvalidZeroizeConfiguration {
message: String,
reason: ZeroizeConfigurationErrorReason,
},
MissingField(&'static str),
InvalidTypePath(String),
JsonPolicyMapKey(String),
MissingWildcard(String),
MissingListPlaceholder(String),
InvalidSyntax(String),
FileNotFound(String),
OutputFileNameConflict {
file_name: String,
first_source: String,
second_source: String,
},
Other(String),
ReservedFieldName {
message_name: String,
field_name: String,
},
ModuleNameConflict {
scope: String,
name_a: String,
name_b: String,
module_name: String,
},
OneofEnumNameConflict {
message_name: String,
first_oneof: String,
second_oneof: String,
rust_name: String,
},
OneofVariantNameConflict {
message_name: String,
oneof_name: String,
first_field: String,
second_field: String,
rust_name: String,
},
TypeNameConflict {
scope: String,
first_type: String,
second_type: String,
rust_name: String,
},
ReservedModuleName {
name: String,
location: String,
},
SharedCorpusContextMismatch {
what: &'static str,
},
MessageSetNotSupported {
message_name: String,
},
InvalidCustomAttribute {
path: String,
attribute: String,
detail: String,
},
InvalidTypeNamePrefix {
prefix: String,
},
DuplicateFieldNumber {
message_name: String,
first_field: String,
second_field: String,
number: i32,
},
}Expand description
Code generation error.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ViewJsonRuleMatchedNothing
A view-export restriction matches no known message.
ZeroizeRuleMatchedNothing
A cleanup selector matches no message in the request’s descriptors.
JsonPolicyTypeMatchedNothing
A listed policy type is not selected by any unshadowed representation rule.
JsonPolicyTypeNearMiss
A representation has the same final type name as a listed policy, but a different spelling.
InvalidZeroizeConfiguration
A selected message cannot satisfy the recursive cleanup contract.
Fields
reason: ZeroizeConfigurationErrorReasonA fixed, typed configuration reason.
MissingField(&'static str)
A required field was absent in a descriptor, or a message or enum name was empty.
The string is the descriptor field, such as message.name or
field.type_name.
InvalidTypePath(String)
A resolved type path string could not be parsed as a Rust type.
JsonPolicyMapKey(String)
A json_policy_types string
type is the key type of an enum-valued map. Policy keys do not yet
support the enum map helpers’ unknown-value filtering. The string is
the map field’s proto path.
MissingWildcard(String)
A box_type_custom pointer template did not contain the * placeholder.
The custom pointer wraps the message type, so the template must mark where
it goes with *, e.g. "::smallbox::SmallBox<*, smallbox::space::S4>".
MissingListPlaceholder(String)
A repeated_type_custom collection template did not contain the *
element placeholder.
Unlike the scalar string_type_custom / bytes_type_custom knobs (which
take a complete type path), a collection template wraps the element type
and must mark where it goes with *, e.g. "::my_crate::SmallList<*>".
InvalidSyntax(String)
The accumulated TokenStream failed to parse as valid Rust syntax.
FileNotFound(String)
A requested file was not present in the descriptor set.
OutputFileNameConflict
Two generated files would be written to the same output path. A
content file is named after its .proto path with / replaced by
., so foo/bar.proto and foo.bar.proto both produce foo.bar.rs;
a package’s module file is <package>.mod.rs, which is also the
content file of foo/mod.proto in package foo.
Resolve by renaming a proto file (the only one involved, when the
other source is a package), or by setting
CodeGenConfig::file_per_package, which emits one file per package
and no per-proto content files.
Fields
Other(String)
Unexpected descriptor state (e.g. a map entry or oneof that cannot be resolved to a known descriptor field).
ReservedFieldName
A proto field name uses the __buffa_ reserved prefix, which would
conflict with buffa’s internal generated fields.
ModuleNameConflict
Two sibling messages produce the same Rust module name after
snake_case conversion (e.g., HTTPRequest and HttpRequest both
become pub mod http_request).
OneofEnumNameConflict
Two oneofs of one message produce the same Rust enum name after
PascalCase conversion and keyword escaping (e.g., foo_bar and
foo__bar both become FooBar; self and self_ both become
Self_). Resolve by renaming one of the oneofs. A oneof’s name is in
neither the wire format nor JSON, so the rename changes generated
code only.
Fields
OneofVariantNameConflict
Two members of one oneof produce the same Rust variant name after
PascalCase conversion and keyword escaping (e.g., foo and foo_
both become Foo; foo_bar and foo__bar both become FooBar;
self and self_ both become Self_). Resolve by renaming one of
the members. A member’s name is its default JSON and text-format
name, so the rename changes those too unless the field sets a
json_name; the wire format is unaffected.
Fields
TypeNameConflict
Two types, each a message or an enum, declared at package level in
one package or nested in one message, produce the same Rust type
name. With an empty CodeGenConfig::type_name_prefix, a type named
after a Rust keyword (type, Self), or after a primitive type that
generated code uses (bool, str, u8, usize, i32, i64,
u32, u64, f32, f64), is generated with a trailing _, so
bool and bool_ both become bool_.
Resolve by renaming one of the types, which changes its full name and
its Any type URL, or by setting a prefix: with prefix Pb the two
types are Pbbool and Pbbool_.
Fields
scope: StringFully-qualified proto name of the package or message that declares both types, without a leading dot. Empty for a package-level conflict in a file that declares no package.
ReservedModuleName
A proto package segment, message name, or file-level enum name
would emit a Rust item matching the reserved sentinel __buffa.
This is the only name buffa reserves in user namespace. Resolve by renaming the proto element.
CodeGenConfig::shared_corpus_context was built from a different
corpus or different oneof/pointer-repr rules than this call’s.
what names the mismatch: "files", "unboxed_oneof_fields", or
"pointer_fields". Build the context with
SharedCorpusContext::new from the same files and config as every
generate() call that uses it.
MessageSetNotSupported
The input contains a message with option message_set_wire_format = true
but CodeGenConfig::allow_message_set was not set.
InvalidCustomAttribute
A custom attribute string configured via CodeGenConfig::type_attributes,
CodeGenConfig::field_attributes, CodeGenConfig::message_attributes,
CodeGenConfig::enum_attributes, CodeGenConfig::oneof_attributes,
or CodeGenConfig::oneof_struct_field_attributes is not one or more
outer #[...] attributes. An empty string, an inner attribute
#![...] and a string with any token outside an attribute are all
rejected, whether or not the rule’s path matches a generated item.
InvalidTypeNamePrefix
CodeGenConfig::type_name_prefix is not PascalCase
([A-Z][A-Za-z0-9]*), so prepending it to a type name would produce
an invalid or unconventionally-cased Rust identifier.
DuplicateFieldNumber
Two fields of one message, in a file being generated, have the same field number. protoc rejects such a message, so the descriptor was built in code or changed after protoc wrote it.
Generated code for it would write both fields with one field number and decode every record with that number into one of them, so the error is returned whichever codec is selected.
Fields
Trait Implementations§
Source§impl Clone for CodeGenError
impl Clone for CodeGenError
Source§impl Debug for CodeGenError
impl Debug for CodeGenError
Source§impl Display for CodeGenError
impl Display for CodeGenError
Source§impl Error for CodeGenError
impl Error for CodeGenError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()