Ctx

Struct Ctx 

Source
pub struct Ctx<'a> {
    pub orig: Args,
    pub args: Vec<&'a OsStr>,
    pub inner_ctx: Option<InnerCtx<'a>>,
    /* private fields */
}
Expand description

The invoke context of option handler. It saved the option information and matched arguments.

Fields§

§orig: Args§args: Vec<&'a OsStr>§inner_ctx: Option<InnerCtx<'a>>

Implementations§

Source§

impl<'a> Ctx<'a>

Source

pub fn with_args(self, args: Vec<&'a OsStr>) -> Self

Source

pub fn with_orig(self, orig_args: Args) -> Self

Source

pub fn with_inner_ctx(self, inner_ctx: InnerCtx<'a>) -> Self

Source§

impl<'a> Ctx<'a>

Source

pub fn uid(&self) -> Result<Uid, Error>

The uid of matched option.

Source

pub fn idx(&self) -> Result<usize, Error>

The index of matched option.

Source

pub fn total(&self) -> Result<usize, Error>

The total number of arguments.

Source

pub fn name(&self) -> Result<Option<&Cow<'a, str>>, Error>

The name of matched option. For option it is the option name, for NOA it is the argument, which set in invoke.

Source

pub fn style(&self) -> Result<Style, Error>

The style of matched option.

Source

pub fn args(&self) -> &[&'a OsStr]

The copy of Args when the option matched. It may be changing during parsing process.

Source

pub fn arg(&self) -> Result<Option<&Cow<'a, OsStr>>, Error>

The argument which set in invoke.

Source

pub fn inner_ctx(&self) -> Result<&InnerCtx<'a>, Error>

Source

pub fn inner_ctx_mut(&mut self) -> Result<&mut InnerCtx<'a>, Error>

Source

pub fn orig(&self) -> &Args

The original arguments passed by user.

Source

pub fn arg_at(&self, idx: usize) -> Result<Option<&'a OsStr>, Error>

The current argument indexed by self.idx().

Source

pub fn take_args(&mut self) -> Vec<&OsStr>

Source

pub fn take_orig_args(&mut self) -> Args

Source§

impl<'a> Ctx<'a>

Source

pub fn set_uid(&mut self, uid: Uid) -> Result<&mut Self, Error>

Source

pub fn set_index(&mut self, index: usize) -> Result<&mut Self, Error>

The index of matching context.

Source

pub fn set_total(&mut self, total: usize) -> Result<&mut Self, Error>

The total of matching context.

Source

pub fn set_args(&mut self, args: Vec<&'a OsStr>) -> &mut Self

Source

pub fn set_name( &mut self, name: Option<Cow<'a, str>>, ) -> Result<&mut Self, Error>

Source

pub fn set_style(&mut self, style: Style) -> Result<&mut Self, Error>

Source

pub fn set_arg( &mut self, arg: Option<Cow<'a, OsStr>>, ) -> Result<&mut Self, Error>

Source

pub fn set_orig_args(&mut self, orig_args: Args) -> &mut Self

Source

pub fn set_inner_ctx(&mut self, inner_ctx: Option<InnerCtx<'a>>) -> &mut Self

Source§

impl Ctx<'_>

Source

pub fn policy_act(&self) -> Action

Source

pub fn set_policy_act(&self, act: Action)

Source

pub fn reset_policy_act(&self)

Source§

impl Ctx<'_>

Source

pub fn value<T: RawValParser>(&self) -> Result<T, Error>

Trait Implementations§

Source§

impl Clone for Ctx<'_>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Ctx<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for Ctx<'a>

Source§

fn default() -> Ctx<'a>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for Ctx<'a>

§

impl<'a> RefUnwindSafe for Ctx<'a>

§

impl<'a> Send for Ctx<'a>

§

impl<'a> Sync for Ctx<'a>

§

impl<'a> Unpin for Ctx<'a>

§

impl<'a> UnwindSafe for Ctx<'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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<'a, C, T> DynamicCtorThenBuilderHelper<'a, C> for T
where C: Match<'a>,

Source§

fn into_ctor_then_builder<F, O1, R>( self, func: F, ) -> DynamicCtorThenBuilder<C, T, F>
where F: Fn(&mut C, &O1) -> Result<R, Error>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T, K> WithDefaultHelper<T> for K

Source§

fn with_default<F>(self, func: F) -> WithDefault<T, F, K>
where F: Fn() -> T,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedTy for T
where T: Any + Debug + Sync + Send + 'static,

Source§

impl<T> MayDebug for T