pub enum ShellValue {
Unset(ShellValueUnsetType),
String(String),
AssociativeArray(BTreeMap<String, String>),
IndexedArray(BTreeMap<u64, String>),
Dynamic {
getter: fn(&Shell) -> ShellValue,
setter: fn(&Shell),
},
}Expand description
A shell value.
Variants§
Unset(ShellValueUnsetType)
A value that has been typed but not yet set.
String(String)
A string.
AssociativeArray(BTreeMap<String, String>)
An associative array.
IndexedArray(BTreeMap<u64, String>)
An indexed array.
Dynamic
A value that is dynamically computed.
Implementations§
Source§impl ShellValue
impl ShellValue
Sourcepub fn indexed_array_from_strings<S>(values: S) -> Selfwhere
S: IntoIterator<Item = String>,
pub fn indexed_array_from_strings<S>(values: S) -> Selfwhere
S: IntoIterator<Item = String>,
Returns a new indexed array value constructed from the given slice of owned strings.
§Arguments
values- The slice of strings to construct the indexed array from.
Sourcepub fn indexed_array_from_strs(values: &[&str]) -> Self
pub fn indexed_array_from_strs(values: &[&str]) -> Self
Returns a new indexed array value constructed from the given slice of unowned strings.
§Arguments
values- The slice of strings to construct the indexed array from.
Sourcepub fn indexed_array_from_literals(literals: ArrayLiteral) -> Self
pub fn indexed_array_from_literals(literals: ArrayLiteral) -> Self
Returns a new indexed array value constructed from the given literals.
§Arguments
literals- The literals to construct the indexed array from.
Sourcepub fn associative_array_from_literals(
literals: ArrayLiteral,
) -> Result<Self, Error>
pub fn associative_array_from_literals( literals: ArrayLiteral, ) -> Result<Self, Error>
Returns a new associative array value constructed from the given literals.
§Arguments
literals- The literals to construct the associative array from.
Sourcepub fn format(
&self,
style: FormatStyle,
shell: &Shell,
) -> Result<Cow<'_, str>, Error>
pub fn format( &self, style: FormatStyle, shell: &Shell, ) -> Result<Cow<'_, str>, Error>
Formats the value using the given style.
§Arguments
style- The style to use for formatting the value.
Sourcepub fn get_at(
&self,
index: &str,
shell: &Shell,
) -> Result<Option<Cow<'_, str>>, Error>
pub fn get_at( &self, index: &str, shell: &Shell, ) -> Result<Option<Cow<'_, str>>, Error>
Tries to retrieve the value stored at the given index in this variable.
§Arguments
index- The index at which to retrieve the value.
Sourcepub fn element_keys(&self, shell: &Shell) -> Vec<String>
pub fn element_keys(&self, shell: &Shell) -> Vec<String>
Returns the keys of the elements in this variable.
Sourcepub fn element_values(&self, shell: &Shell) -> Vec<String>
pub fn element_values(&self, shell: &Shell) -> Vec<String>
Returns the values of the elements in this variable.
Sourcepub fn to_cow_str(&self, shell: &Shell) -> Cow<'_, str>
pub fn to_cow_str(&self, shell: &Shell) -> Cow<'_, str>
Converts this value to a string.
Trait Implementations§
Source§impl Clone for ShellValue
impl Clone for ShellValue
Source§fn clone(&self) -> ShellValue
fn clone(&self) -> ShellValue
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ShellValue
impl Debug for ShellValue
Source§impl From<&String> for ShellValue
impl From<&String> for ShellValue
Source§impl From<&str> for ShellValue
impl From<&str> for ShellValue
Source§impl From<String> for ShellValue
impl From<String> for ShellValue
Auto Trait Implementations§
impl Freeze for ShellValue
impl RefUnwindSafe for ShellValue
impl Send for ShellValue
impl Sync for ShellValue
impl Unpin for ShellValue
impl UnwindSafe for ShellValue
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more