pub enum ArgumentValue {
Scalar(String),
List(Vec<String>),
}Expand description
One value supplied for a declared parameter.
Two shapes, because a caller can SUPPLY two shapes — but only one of them
renders. A command parameter is one command-line word, so a single value
becomes that word; a list has no rendering at all and is refused by name,
with both shapes stated, before any argv exists
(super::DeclaredCommandContract::render). The list shape is carried
here precisely so that refusal can see it and say what arrived, rather
than joining it into a string nobody wrote.
Variants§
Scalar(String)
A single value, rendered as written.
List(Vec<String>)
Several values supplied at once, which no declared parameter accepts: carried so the refusal can name the shape that arrived.
Implementations§
Source§impl ArgumentValue
impl ArgumentValue
Sourcepub fn describe(&self) -> String
pub fn describe(&self) -> String
How a diagnostic names this value, without pretending a list is a string.
Sourcepub fn from_json(parameter: &str, value: &Value) -> Result<Self, RenderError>
pub fn from_json(parameter: &str, value: &Value) -> Result<Self, RenderError>
The argument value a JSON dispatch input carries for parameter.
Strings, numbers and booleans have one obvious argument spelling and
take it. An array becomes a list, provided every item is itself one of
those three. null and an object have no single obvious spelling —
guessing one (empty string? JSON text? space-joined?) would make the
command mean something the author never wrote — so each is refused by
name.
§Errors
Returns RenderError::UnrepresentableValue for a value with no
unambiguous argument form, and RenderError::InteriorNul for a
string carrying a NUL byte, which the kernel would silently truncate
the argument at.
Trait Implementations§
Source§impl Clone for ArgumentValue
impl Clone for ArgumentValue
Source§fn clone(&self) -> ArgumentValue
fn clone(&self) -> ArgumentValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ArgumentValue
impl Debug for ArgumentValue
impl Eq for ArgumentValue
Source§impl PartialEq for ArgumentValue
impl PartialEq for ArgumentValue
impl StructuralPartialEq for ArgumentValue
Auto Trait Implementations§
impl Freeze for ArgumentValue
impl RefUnwindSafe for ArgumentValue
impl Send for ArgumentValue
impl Sync for ArgumentValue
impl Unpin for ArgumentValue
impl UnsafeUnpin for ArgumentValue
impl UnwindSafe for ArgumentValue
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.