pub enum Scalar {
Text(Text),
Integer(Bounds<i64>),
Number(Bounds<f64>),
Boolean,
Choice(Vec<String>),
}Expand description
What one flag accepts, as the document describes it.
Eq is absent on purpose: a number’s bounds are f64, which has none.
Variants§
Text(Text)
type: string, with whatever the document states about it.
Integer(Bounds<i64>)
type: integer, with whatever the document states about it.
Number(Bounds<f64>)
type: number, with whatever the document states about it.
Boolean
type: boolean.
Choice(Vec<String>)
enum: [..] on a string schema. These values complete.
Implementations§
Source§impl Scalar
impl Scalar
Sourcepub fn parse(&self, raw: &str) -> Result<Value, ScalarError>
pub fn parse(&self, raw: &str) -> Result<Value, ScalarError>
Turn one raw argument into the JSON value the wire wants, or refuse it the way the document does.
Sourcepub fn runnable(&self) -> Result<(), ScalarError>
pub fn runnable(&self) -> Result<(), ScalarError>
Whether every rule this carries can be run at all.
A pattern the engine cannot read is the only rule that can fail this
way, and it fails on every value — so a document is held to this while
it is reduced, and the failure names the operation rather than turning
up at a user’s flag.
Sourcepub fn value_name(&self) -> &'static str
pub fn value_name(&self) -> &'static str
The <NAME> shown for the flag’s value, and the closest thing the
document gives an agent to a type.
Sourcepub fn note(&self) -> Option<String>
pub fn note(&self) -> Option<String>
Everything the document constrains about this value, for the flag’s help
line. Every note is a rule Scalar::parse enforces, in the document’s
own numbers — help and refusal cannot come apart, because one rendering
serves both.