pub struct SchemaValueParser<T>{ /* private fields */ }Expand description
A clap [TypedValueParser] that uses schemars::JsonSchema to surface
enum variants as possible values, and std::str::FromStr for actual parsing.
When T is an enum deriving JsonSchema, its variants appear in --help
output and clap’s error messages with no extra derives on the user type.
For non-enum types (e.g. String, u32), this is a transparent pass-through
to FromStr.
Used automatically by #[cli]-generated code when both the cli and
jsonschema features are enabled.
Implementations§
Source§impl<T> SchemaValueParser<T>
impl<T> SchemaValueParser<T>
pub fn new() -> SchemaValueParser<T>
Trait Implementations§
Source§impl<T> Clone for SchemaValueParser<T>
impl<T> Clone for SchemaValueParser<T>
Source§fn clone(&self) -> SchemaValueParser<T>
fn clone(&self) -> SchemaValueParser<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Default for SchemaValueParser<T>
Available on crate features cli and jsonschema only.
impl<T> Default for SchemaValueParser<T>
Available on crate features
cli and jsonschema only.Source§fn default() -> SchemaValueParser<T>
fn default() -> SchemaValueParser<T>
Returns the “default value” for a type. Read more
Source§impl<T> TypedValueParser for SchemaValueParser<T>
Available on crate features cli and jsonschema only.
impl<T> TypedValueParser for SchemaValueParser<T>
Available on crate features
cli and jsonschema only.Source§fn parse_ref(
&self,
_cmd: &Command,
_arg: Option<&Arg>,
value: &OsStr,
) -> Result<T, Error>
fn parse_ref( &self, _cmd: &Command, _arg: Option<&Arg>, value: &OsStr, ) -> Result<T, Error>
Parse the argument value Read more
Source§fn possible_values(
&self,
) -> Option<Box<dyn Iterator<Item = PossibleValue> + '_>>
fn possible_values( &self, ) -> Option<Box<dyn Iterator<Item = PossibleValue> + '_>>
Reflect on enumerated value properties Read more
Source§fn parse_ref_(
&self,
cmd: &Command,
arg: Option<&Arg>,
value: &OsStr,
_source: ValueSource,
) -> Result<Self::Value, Error>
fn parse_ref_( &self, cmd: &Command, arg: Option<&Arg>, value: &OsStr, _source: ValueSource, ) -> Result<Self::Value, Error>
Parse the argument value Read more
Source§fn parse(
&self,
cmd: &Command,
arg: Option<&Arg>,
value: OsString,
) -> Result<Self::Value, Error>
fn parse( &self, cmd: &Command, arg: Option<&Arg>, value: OsString, ) -> Result<Self::Value, Error>
Parse the argument value Read more
Source§fn parse_(
&self,
cmd: &Command,
arg: Option<&Arg>,
value: OsString,
_source: ValueSource,
) -> Result<Self::Value, Error>
fn parse_( &self, cmd: &Command, arg: Option<&Arg>, value: OsString, _source: ValueSource, ) -> Result<Self::Value, Error>
Parse the argument value Read more
Source§fn map<T, F>(self, func: F) -> MapValueParser<Self, F>
fn map<T, F>(self, func: F) -> MapValueParser<Self, F>
Adapt a
TypedValueParser from one value to another Read moreAuto Trait Implementations§
impl<T> Freeze for SchemaValueParser<T>
impl<T> RefUnwindSafe for SchemaValueParser<T>where
T: RefUnwindSafe,
impl<T> Send for SchemaValueParser<T>
impl<T> Sync for SchemaValueParser<T>
impl<T> Unpin for SchemaValueParser<T>where
T: Unpin,
impl<T> UnsafeUnpin for SchemaValueParser<T>
impl<T> UnwindSafe for SchemaValueParser<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<I> IntoResettable<ValueParser> for Iwhere
I: Into<ValueParser>,
impl<I> IntoResettable<ValueParser> for Iwhere
I: Into<ValueParser>,
Source§fn into_resettable(self) -> Resettable<ValueParser>
fn into_resettable(self) -> Resettable<ValueParser>
Convert to the intended resettable type