Skip to main content

ValueProvider

Type Alias ValueProvider 

Source
pub type ValueProvider = Arc<dyn Fn(&str, &[&str]) -> Vec<String> + Send + Sync>;
Expand description

A function that provides dynamic completion values for a specific option.

Called when the user tabs after an option that has a registered provider. Receives the partial word being typed and the full context of completed words on the command line (excluding the program name and the partial). Heap-allocated, thread-safe closure type so providers can capture data (e.g., a static enum-value list discovered from a CommandOp::value_completions map). Function pointers can be promoted to this type via [ValueProvider::from_fn] so existing fn(&str, &[&str]) -> Vec<String> providers keep working.

Aliased Type§

pub struct ValueProvider { /* private fields */ }

Trait Implementations§

Source§

impl From<ClosedValues> for ValueProvider

Convenience: hand any ClosedValues to APIs that take a ValueProvider without explicit .into_provider().

Source§

fn from(cv: ClosedValues) -> Self

Converts to this type from the input type.