Skip to main content

package_is_excluded

Function package_is_excluded 

Source
pub fn package_is_excluded(package: &str, excludes: &[String]) -> bool
Expand description

Returns true if package is covered by any entry in excludes.

Intended for packages that include_imports pulls into file_to_generate but that a caller does not want emitted — typically option-only imports such as buf.validate or gnostic.openapi.v3, whose types are referenced only from custom options and never appear as message fields.

An exclusion matches a package exactly, or as a dotted-path prefix on a component boundary: "buf.validate" covers buf.validate and buf.validate.foo, but not buf.validatex. Entries are proto package paths without a leading dot (buf.validate, not .buf.validate); an empty entry matches only the unnamed package.

Both protoc-gen-buffa (which filters file_to_generate before codegen) and protoc-gen-buffa-packaging (which filters the packages it stitches into mod.rs) route their exclusion through this one predicate, so the two plugins are guaranteed to drop exactly the same set — the invariant the packaging plugin’s “Matching a codegen plugin’s output set” note depends on.