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>
impl<'a> Ctx<'a>
Sourcepub fn name(&self) -> Result<Option<&Cow<'a, str>>, Error>
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.
Sourcepub fn args(&self) -> &[&'a OsStr]
pub fn args(&self) -> &[&'a OsStr]
The copy of Args when the option matched.
It may be changing during parsing process.
pub fn inner_ctx(&self) -> Result<&InnerCtx<'a>, Error>
pub fn inner_ctx_mut(&mut self) -> Result<&mut InnerCtx<'a>, Error>
Sourcepub fn arg_at(&self, idx: usize) -> Result<Option<&'a OsStr>, Error>
pub fn arg_at(&self, idx: usize) -> Result<Option<&'a OsStr>, Error>
The current argument indexed by self.idx().
pub fn take_args(&mut self) -> Vec<&OsStr>
pub fn take_orig_args(&mut self) -> Args
Source§impl<'a> Ctx<'a>
impl<'a> Ctx<'a>
pub fn set_uid(&mut self, uid: Uid) -> Result<&mut Self, Error>
Sourcepub fn set_index(&mut self, index: usize) -> Result<&mut Self, Error>
pub fn set_index(&mut self, index: usize) -> Result<&mut Self, Error>
The index of matching context.
Sourcepub fn set_total(&mut self, total: usize) -> Result<&mut Self, Error>
pub fn set_total(&mut self, total: usize) -> Result<&mut Self, Error>
The total of matching context.
pub fn set_args(&mut self, args: Vec<&'a OsStr>) -> &mut Self
pub fn set_name( &mut self, name: Option<Cow<'a, str>>, ) -> Result<&mut Self, Error>
pub fn set_style(&mut self, style: Style) -> Result<&mut Self, Error>
pub fn set_arg( &mut self, arg: Option<Cow<'a, OsStr>>, ) -> Result<&mut Self, Error>
pub fn set_orig_args(&mut self, orig_args: Args) -> &mut Self
pub fn set_inner_ctx(&mut self, inner_ctx: Option<InnerCtx<'a>>) -> &mut Self
Source§impl Ctx<'_>
impl Ctx<'_>
pub fn policy_act(&self) -> Action
pub fn set_policy_act(&self, act: Action)
pub fn reset_policy_act(&self)
Trait Implementations§
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> UnsafeUnpin for Ctx<'a>
impl<'a> UnwindSafe for Ctx<'a>
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