Skip to main content

generate_with_diagnostics

Function generate_with_diagnostics 

Source
pub fn generate_with_diagnostics(
    file_descriptors: &[FileDescriptorProto],
    files_to_generate: &[String],
    config: &CodeGenConfig,
) -> Result<(Vec<GeneratedFile>, Vec<CodeGenWarning>), CodeGenError>
Expand description

Like generate, but also returns the non-fatal CodeGenWarnings collected during generation (e.g. enums whose idiomatic CamelCase aliases were suppressed by a naming conflict).

Report each warning through its Display impl — e.g. as a cargo:warning=... from a build.rs, or on stderr from a standalone generator — or match on it for programmatic handling. generate discards them.

A name listed twice in files_to_generate is generated once.

Warnings are returned only on success. On error, any warnings already collected are dropped along with the partial output — the CodeGenError is the actionable signal.

§Errors