Skip to main content

normalize_exclude_package

Function normalize_exclude_package 

Source
pub fn normalize_exclude_package(value: &str) -> Result<String, String>
Expand description

Normalize and validate one exclude_package option value: trim whitespace, strip the optional leading dot, reject an empty result or a value with empty components (buf.validate., buf..validate) — those could never match a real package, so a typo would otherwise be a silent no-op.

Both protoc plugins parse their exclude_package options through this one function so their normalization cannot drift — the same reason they share package_is_excluded.

§Errors

Returns the user-facing message for a malformed value. The error is a plain String (not CodeGenError) deliberately: this is plugin option-string parsing, and both plugins’ parse layers are Result<_, String> end to end, surfaced verbatim by protoc.