pub struct ArgsExtractor<'a> {
args: &'a ExtensionArgs,
consumed: HashSet<&'a str>,
checked: bool,
}Expand description
Helper struct for extracting named arguments with validation.
Tracks which arguments have been consumed. Callers must call
check_exhausted before dropping to
verify no unexpected arguments remain. In debug builds, dropping without
calling check_exhausted will panic (matching the [RuleIter] pattern).
Fields§
§args: &'a ExtensionArgs§consumed: HashSet<&'a str>§checked: boolImplementations§
Source§impl<'a> ArgsExtractor<'a>
impl<'a> ArgsExtractor<'a>
Sourcepub fn new(args: &'a ExtensionArgs) -> Self
pub fn new(args: &'a ExtensionArgs) -> Self
Create a new extractor for the given arguments
Sourcepub fn get_named_arg(&mut self, name: &str) -> Option<&'a ExtensionValue>
pub fn get_named_arg(&mut self, name: &str) -> Option<&'a ExtensionValue>
Get a named argument value, marking it as consumed if found.
Sourcepub fn expect_named_arg<T>(&mut self, name: &str) -> Result<T, ExtensionError>
pub fn expect_named_arg<T>(&mut self, name: &str) -> Result<T, ExtensionError>
Get a named argument value or return an error Marks the argument as consumed if found
Sourcepub fn get_named_or<T>(
&mut self,
name: &str,
default: T,
) -> Result<T, ExtensionError>
pub fn get_named_or<T>( &mut self, name: &str, default: T, ) -> Result<T, ExtensionError>
Get a named argument value or default Marks the argument as consumed if it exists in the source args
Sourcepub fn check_exhausted(&mut self) -> Result<(), ExtensionError>
pub fn check_exhausted(&mut self) -> Result<(), ExtensionError>
Check that all named arguments in the source have been consumed, returning an error if not.
Must be called before the extractor is dropped, to validate that all args are correctly handled. In debug builds, dropping without calling this method will panic.