pub enum ArgValue {
String(String),
Char(char),
Bool(bool),
Int(i64),
Pattern(String),
Chord(String),
Invocation(Box<CommandInvocation>),
Raw(String),
}Expand description
One argument’s typed value. The variants mirror ArgKind one-for-one.
Variants§
String(String)
Free-form text.
Char(char)
A single character.
Bool(bool)
A flag (e.g. a transient switch).
Int(i64)
A signed integer.
Pattern(String)
A pattern – regex when v1 grows regex; literal substring today.
Chord(String)
A keyboard chord in canonical notation (<C-c>, <Esc>, gg,
<C-S-x>). Stored as a string so the value layer doesn’t need
to know about crossterm / KeyEvent; the UI captures raw key
events and renders them via format_chord before the value
reaches here. Used by :describe-key and (later) :map,
:nnoremap, etc.
Invocation(Box<CommandInvocation>)
A nested invocation. Used by :g/.../body where the body is a
command in its own right; the parser front-end produces a
CommandInvocation and the host dispatches it per match. Boxed
because Args lives inside CommandInvocation.
Raw(String)
Raw text whose parsing was deferred. v1 uses this for :g’s
body string (re-parsed per line by the host) until we promote
body to a parsed Invocation.
Implementations§
Source§impl ArgValue
impl ArgValue
Sourcepub fn kind(&self) -> ArgKind
pub fn kind(&self) -> ArgKind
The ArgKind tag for this value (ArgValue::Invocation maps to
ArgKind::Body; every other variant to its namesake).
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Borrow the text of any string-shaped value (String, Pattern,
Chord, Raw); None for Char, Bool, Int, Invocation.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
The flag of an ArgValue::Bool; None for every other variant
(no truthiness coercion).
Sourcepub fn as_invocation(&self) -> Option<&CommandInvocation>
pub fn as_invocation(&self) -> Option<&CommandInvocation>
Extract a parsed sub-invocation. Used by :g’s body slot to
pull the pre-parsed CommandInvocation out at apply time.