Skip to main content

CodeGenError

Enum CodeGenError 

Source
#[non_exhaustive]
pub enum CodeGenError {
Show 28 variants Adapter(AdapterError), CleanupJsonAttribute(CleanupJsonAttributeErrorReason), ViewJsonRuleMatchedNothing { rule: String, }, BorrowedViewsRuleMatchedNothing { rule_index: usize, }, 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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Adapter(AdapterError)

Native adapter metadata failed validation; input values are redacted.

§

CleanupJsonAttribute(CleanupJsonAttributeErrorReason)

A cleanup JSON visitor cannot preserve a caller input policy.

§

ViewJsonRuleMatchedNothing

A view-export restriction matches no known message.

Fields

§rule: String
§

BorrowedViewsRuleMatchedNothing

A borrowed-view selector matches no known message.

Fields

§rule_index: usize

Zero-based index in the configured selector list.

§

ZeroizeRuleMatchedNothing

A cleanup selector matches no message in the request’s descriptors.

Fields

§rule: String
§

JsonPolicyTypeMatchedNothing

A listed policy type is not selected by any unshadowed representation rule.

Fields

§rust_type: String
§

JsonPolicyTypeNearMiss

A representation has the same final type name as a listed policy, but a different spelling.

Fields

§selected: String
§listed: String
§

InvalidZeroizeConfiguration

A selected message cannot satisfy the recursive cleanup contract.

Fields

§message: String

Protobuf message name from the schema.

§reason: ZeroizeConfigurationErrorReason

A 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, or is not a type path where a custom field representation requires one.

§

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

§file_name: String

The output path that both inputs map to.

§first_source: String

The input that generated the path first: the .proto file path as its descriptor names it for a content file, or package <name> (the unnamed package for a file that declares no package) for a package’s module file.

§second_source: String

The input that generated the path second, in the same form as first_source.

§

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.

Fields

§message_name: String
§field_name: String
§

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).

Fields

§scope: String
§name_a: String
§name_b: String
§module_name: String
§

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

§message_name: String

Fully-qualified proto name of the message, without a leading dot.

§first_oneof: String

Proto name of the oneof declared first.

§second_oneof: String

Proto name of the oneof declared second.

§rust_name: String

The Rust enum name that both oneofs map to.

§

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

§message_name: String

Fully-qualified proto name of the message, without a leading dot.

§oneof_name: String

Proto name of the oneof that declares both members.

§first_field: String

Proto name of the member declared first.

§second_field: String

Proto name of the member declared second.

§rust_name: String

The Rust variant name that both members map to.

§

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: String

Fully-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.

§first_type: String

Proto simple name of the type visited first: within each file, messages in declaration order, then enums.

§second_type: String

Proto simple name of the type visited second.

§rust_name: String

The Rust type name that both map to.

§

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.

Fields

§name: String
§location: String
§

SharedCorpusContextMismatch

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.

Fields

§what: &'static str
§

MessageSetNotSupported

The input contains a message with option message_set_wire_format = true but CodeGenConfig::allow_message_set was not set.

Fields

§message_name: String
§

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.

Fields

§path: String
§attribute: String
§detail: String
§

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.

Fields

§prefix: String
§

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

§message_name: String

The message’s full name, without a leading dot.

§first_field: String

The name of the field declared first.

§second_field: String

The name of the field declared second.

§number: i32

The number both fields have, as the descriptor gives it. It may be outside the valid range for a field number.

Trait Implementations§

Source§

impl Clone for CodeGenError

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CodeGenError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for CodeGenError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for CodeGenError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<AdapterError> for CodeGenError

Source§

fn from(source: AdapterError) -> Self

Converts to this type from the input type.
Source§

impl From<ErrorReason> for CodeGenError

Source§

fn from(source: CleanupJsonAttributeErrorReason) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.