Skip to main content

generate_module_tree

Function generate_module_tree 

Source
pub fn generate_module_tree(
    entries: &[(&str, &str)],
    include_prefix: &str,
    emit_inner_allow: bool,
) -> String
Expand description

Generate a module tree that assembles generated .rs files into nested pub mod blocks matching the protobuf package hierarchy.

Each entry is a (file_name, package) pair where package is the dot-separated protobuf package name (e.g., "google.api"). The module tree is built from the package hierarchy so that super::-based cross-package references resolve correctly.

include_prefix is prepended to file names in include! directives. Use "" for relative paths or concat!(env!("OUT_DIR"), "/") style for build.rs output.

When emit_inner_allow is true, a #![allow(...)] inner attribute is emitted at the top of the file. This is appropriate when the output is used directly as a module file (e.g., mod.rs) but NOT when the output is consumed via include! (inner attributes are not valid in that context).