Skip to main content

generate

Function generate 

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

Generate Rust source files from a set of file descriptors.

files_to_generate is the set of file names that were explicitly requested (matching CodeGeneratorRequest.file_to_generate). Descriptors for dependencies may be present in file_descriptors but won’t produce output files unless they appear in files_to_generate.

Each .proto emits up to five content files (kinds with no content are omitted); each distinct package emits one <pkg>.mod.rs stitcher. Packages are processed in sorted order for deterministic output.

§Diagnostics

Non-fatal diagnostics produced during generation (e.g. an enum whose idiomatic CamelCase aliases were suppressed by a naming conflict) are discarded here. Use generate_with_diagnostics to receive them and surface them as build warnings.