ArgsExtractor

Struct ArgsExtractor 

Source
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: bool

Implementations§

Source§

impl<'a> ArgsExtractor<'a>

Source

pub fn new(args: &'a ExtensionArgs) -> Self

Create a new extractor for the given arguments

Source

pub fn get_named_arg(&mut self, name: &str) -> Option<&'a ExtensionValue>

Get a named argument value, marking it as consumed if found.

Source

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

Source

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

Source

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.

Trait Implementations§

Source§

impl Drop for ArgsExtractor<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ArgsExtractor<'a>

§

impl<'a> RefUnwindSafe for ArgsExtractor<'a>

§

impl<'a> Send for ArgsExtractor<'a>

§

impl<'a> Sync for ArgsExtractor<'a>

§

impl<'a> Unpin for ArgsExtractor<'a>

§

impl<'a> UnwindSafe for ArgsExtractor<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.