pub trait AnyTypeConverter: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn convert_any(
&self,
value: &str,
) -> Result<Box<dyn Any + Send + Sync>, String>;
fn convert_multi(
&self,
values: &[String],
) -> Result<Box<dyn Any + Send + Sync>, String>;
fn get_metavar(&self) -> Option<String>;
fn split_envvar_value(&self, value: &str) -> Vec<String>;
fn shell_complete(&self, incomplete: &str) -> Vec<CompletionItem>;
}Expand description
A type-erased wrapper for TypeConverter that stores converted values as Box<dyn Any>.
This allows arguments to work with any TypeConverter, not just those returning String.
Required Methods§
Sourcefn convert_any(&self, value: &str) -> Result<Box<dyn Any + Send + Sync>, String>
fn convert_any(&self, value: &str) -> Result<Box<dyn Any + Send + Sync>, String>
Convert a string value to the target type, returning as Box
Sourcefn convert_multi(
&self,
values: &[String],
) -> Result<Box<dyn Any + Send + Sync>, String>
fn convert_multi( &self, values: &[String], ) -> Result<Box<dyn Any + Send + Sync>, String>
Convert multiple string values to the target type, returning as Box
By default this returns a Vec of the underlying type.
Sourcefn get_metavar(&self) -> Option<String>
fn get_metavar(&self) -> Option<String>
Returns the metavar for this type.
Sourcefn split_envvar_value(&self, value: &str) -> Vec<String>
fn split_envvar_value(&self, value: &str) -> Vec<String>
Split an environment variable value into multiple values.
Sourcefn shell_complete(&self, incomplete: &str) -> Vec<CompletionItem>
fn shell_complete(&self, incomplete: &str) -> Vec<CompletionItem>
Returns shell completion items for the given incomplete value.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".