Trait parkour::prelude::FromInputValue[][src]

pub trait FromInputValue: Sized {
    type Context;
    fn from_input_value(
        value: &str,
        context: &Self::Context
    ) -> Result<Self, Error>; fn allow_leading_dashes(_context: &Self::Context) -> bool { ... } }

Trait for parsing a value. A value can be

  • a positional argument
  • a string following a flag; e.g in --foo bar or --foo=bar, the bar part is a value. A flag can be followed by multiple values, e.g. --foo bar baz or --foo=bar,baz

To parse values, they are first converted to a string slice. By default, an argument that starts with a dash can't be parsed as a value, unless you implement the allow_leading_dashes method.

Associated Types

type Context[src]

Information that is available while parsing

Loading content...

Required methods

fn from_input_value(value: &str, context: &Self::Context) -> Result<Self, Error>[src]

The function that parses the string. This function is usually not invoked directly. Instead you can use Parse::parse_value and Parse::try_parse_value:

let mut input = parkour::parser();
let n: i32 = input.parse_value(&NumberCtx { min: -1000, max: 1000 })?;
Loading content...

Provided methods

fn allow_leading_dashes(_context: &Self::Context) -> bool[src]

This function specifies whether this argument may start with leading dashes. For example, this returns true for numbers that can be negative. The default is false.

Loading content...

Implementations on Foreign Types

impl<T: FromInputValue, const N: usize> FromInputValue for [T; N][src]

type Context = ArrayCtx<T::Context>

impl FromInputValue for bool[src]

type Context = ()

impl FromInputValue for char[src]

type Context = ()

impl<T: FromInputValue<Context = C>, C> FromInputValue for Vec<T>[src]

type Context = ListCtx<C>

impl<T: FromInputValue<Context = C>, C> FromInputValue for VecDeque<T>[src]

type Context = ListCtx<C>

impl<T: FromInputValue<Context = C>, C> FromInputValue for LinkedList<T>[src]

type Context = ListCtx<C>

impl<T: FromInputValue<Context = C> + Ord, C> FromInputValue for BTreeSet<T>[src]

type Context = ListCtx<C>

impl<T: FromInputValue<Context = C> + Hash + Eq, C> FromInputValue for HashSet<T>[src]

type Context = ListCtx<C>

impl FromInputValue for i8[src]

type Context = NumberCtx<i8>

impl FromInputValue for i16[src]

type Context = NumberCtx<i16>

impl FromInputValue for i32[src]

type Context = NumberCtx<i32>

impl FromInputValue for i64[src]

type Context = NumberCtx<i64>

impl FromInputValue for i128[src]

type Context = NumberCtx<i128>

impl FromInputValue for isize[src]

type Context = NumberCtx<isize>

impl FromInputValue for NonZeroI8[src]

type Context = NumberCtx<NonZeroI8>

impl FromInputValue for NonZeroI16[src]

type Context = NumberCtx<NonZeroI16>

impl FromInputValue for NonZeroI32[src]

type Context = NumberCtx<NonZeroI32>

impl FromInputValue for NonZeroI64[src]

type Context = NumberCtx<NonZeroI64>

impl FromInputValue for NonZeroI128[src]

type Context = NumberCtx<NonZeroI128>

impl FromInputValue for NonZeroIsize[src]

type Context = NumberCtx<NonZeroIsize>

impl FromInputValue for u8[src]

type Context = NumberCtx<u8>

impl FromInputValue for u16[src]

type Context = NumberCtx<u16>

impl FromInputValue for u32[src]

type Context = NumberCtx<u32>

impl FromInputValue for u64[src]

type Context = NumberCtx<u64>

impl FromInputValue for u128[src]

type Context = NumberCtx<u128>

impl FromInputValue for usize[src]

type Context = NumberCtx<usize>

impl FromInputValue for NonZeroU8[src]

type Context = NumberCtx<NonZeroU8>

impl FromInputValue for NonZeroU16[src]

type Context = NumberCtx<NonZeroU16>

impl FromInputValue for NonZeroU32[src]

type Context = NumberCtx<NonZeroU32>

impl FromInputValue for NonZeroU64[src]

type Context = NumberCtx<NonZeroU64>

impl FromInputValue for NonZeroU128[src]

type Context = NumberCtx<NonZeroU128>

impl FromInputValue for NonZeroUsize[src]

type Context = NumberCtx<NonZeroUsize>

impl FromInputValue for f32[src]

type Context = NumberCtx<f32>

impl FromInputValue for f64[src]

type Context = NumberCtx<f64>

impl FromInputValue for String[src]

type Context = StringCtx

impl FromInputValue for OsString[src]

type Context = StringCtx

impl FromInputValue for PathBuf[src]

type Context = StringCtx

impl FromInputValue for Cow<'static, str>[src]

type Context = StringCtx

impl<T1: FromInputValue> FromInputValue for (T1,)[src]

type Context = TupleCtx<(T1::Context,)>

impl<T1: FromInputValue, T2: FromInputValue> FromInputValue for (T1, T2)[src]

type Context = TupleCtx<(T1::Context, T2::Context)>

impl<T1: FromInputValue, T2: FromInputValue, T3: FromInputValue> FromInputValue for (T1, T2, T3)[src]

type Context = TupleCtx<(T1::Context, T2::Context, T3::Context)>

impl<T1: FromInputValue, T2: FromInputValue, T3: FromInputValue, T4: FromInputValue> FromInputValue for (T1, T2, T3, T4)[src]

type Context = TupleCtx<(T1::Context, T2::Context, T3::Context, T4::Context)>

impl<T1: FromInputValue, T2: FromInputValue, T3: FromInputValue, T4: FromInputValue, T5: FromInputValue> FromInputValue for (T1, T2, T3, T4, T5)[src]

type Context = TupleCtx<(T1::Context, T2::Context, T3::Context, T4::Context, T5::Context)>

impl<T1: FromInputValue, T2: FromInputValue, T3: FromInputValue, T4: FromInputValue, T5: FromInputValue, T6: FromInputValue> FromInputValue for (T1, T2, T3, T4, T5, T6)[src]

type Context = TupleCtx<(T1::Context, T2::Context, T3::Context, T4::Context, T5::Context, T6::Context)>

impl<T1: FromInputValue, T2: FromInputValue, T3: FromInputValue, T4: FromInputValue, T5: FromInputValue, T6: FromInputValue, T7: FromInputValue> FromInputValue for (T1, T2, T3, T4, T5, T6, T7)[src]

type Context = TupleCtx<(T1::Context, T2::Context, T3::Context, T4::Context, T5::Context, T6::Context, T7::Context)>

impl<T1: FromInputValue, T2: FromInputValue, T3: FromInputValue, T4: FromInputValue, T5: FromInputValue, T6: FromInputValue, T7: FromInputValue, T8: FromInputValue> FromInputValue for (T1, T2, T3, T4, T5, T6, T7, T8)[src]

type Context = TupleCtx<(T1::Context, T2::Context, T3::Context, T4::Context, T5::Context, T6::Context, T7::Context, T8::Context)>

impl<T1: FromInputValue, T2: FromInputValue, T3: FromInputValue, T4: FromInputValue, T5: FromInputValue, T6: FromInputValue, T7: FromInputValue, T8: FromInputValue, T9: FromInputValue> FromInputValue for (T1, T2, T3, T4, T5, T6, T7, T8, T9)[src]

type Context = TupleCtx<(T1::Context, T2::Context, T3::Context, T4::Context, T5::Context, T6::Context, T7::Context, T8::Context, T9::Context)>

impl<T1: FromInputValue, T2: FromInputValue, T3: FromInputValue, T4: FromInputValue, T5: FromInputValue, T6: FromInputValue, T7: FromInputValue, T8: FromInputValue, T9: FromInputValue, T10: FromInputValue> FromInputValue for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)[src]

type Context = TupleCtx<(T1::Context, T2::Context, T3::Context, T4::Context, T5::Context, T6::Context, T7::Context, T8::Context, T9::Context, T10::Context)>

impl<T1: FromInputValue, T2: FromInputValue, T3: FromInputValue, T4: FromInputValue, T5: FromInputValue, T6: FromInputValue, T7: FromInputValue, T8: FromInputValue, T9: FromInputValue, T10: FromInputValue, T11: FromInputValue> FromInputValue for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)[src]

type Context = TupleCtx<(T1::Context, T2::Context, T3::Context, T4::Context, T5::Context, T6::Context, T7::Context, T8::Context, T9::Context, T10::Context, T11::Context)>

impl<T1: FromInputValue, T2: FromInputValue, T3: FromInputValue, T4: FromInputValue, T5: FromInputValue, T6: FromInputValue, T7: FromInputValue, T8: FromInputValue, T9: FromInputValue, T10: FromInputValue, T11: FromInputValue, T12: FromInputValue> FromInputValue for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)[src]

type Context = TupleCtx<(T1::Context, T2::Context, T3::Context, T4::Context, T5::Context, T6::Context, T7::Context, T8::Context, T9::Context, T10::Context, T11::Context, T12::Context)>

impl<T: FromInputValue> FromInputValue for Box<T>[src]

type Context = T::Context

impl<T: FromInputValue> FromInputValue for Rc<T>[src]

type Context = T::Context

impl<T: FromInputValue> FromInputValue for Arc<T>[src]

type Context = T::Context

impl<T: FromInputValue> FromInputValue for Cell<T>[src]

type Context = T::Context

impl<T: FromInputValue> FromInputValue for RefCell<T>[src]

type Context = T::Context

impl<T: FromInputValue> FromInputValue for UnsafeCell<T>[src]

type Context = T::Context

impl<T: FromInputValue> FromInputValue for Mutex<T>[src]

type Context = T::Context

impl<T: FromInputValue> FromInputValue for RwLock<T>[src]

type Context = T::Context

impl<T: FromInputValue> FromInputValue for ManuallyDrop<T>[src]

type Context = T::Context

impl<T: ToOwned> FromInputValue for Cow<'static, T> where
    T::Owned: FromInputValue
[src]

type Context = <T::Owned as FromInputValue>::Context

Loading content...

Implementors

Loading content...