pub struct ShellVariable { /* private fields */ }
Expand description
A shell variable.
Implementations§
Source§impl ShellVariable
impl ShellVariable
Sourcepub fn new<I: Into<ShellValue>>(value: I) -> Self
pub fn new<I: Into<ShellValue>>(value: I) -> Self
Returns a new shell variable, initialized with the given value.
§Arguments
value
- The value to associate with the variable.
Sourcepub const fn value(&self) -> &ShellValue
pub const fn value(&self) -> &ShellValue
Returns the value associated with the variable.
Sourcepub const fn is_exported(&self) -> bool
pub const fn is_exported(&self) -> bool
Returns whether or not the variable is exported to child processes.
Sourcepub const fn unexport(&mut self) -> &mut Self
pub const fn unexport(&mut self) -> &mut Self
Marks the variable as not exported to child processes.
Sourcepub const fn is_readonly(&self) -> bool
pub const fn is_readonly(&self) -> bool
Returns whether or not the variable is read-only.
Sourcepub const fn set_readonly(&mut self) -> &mut Self
pub const fn set_readonly(&mut self) -> &mut Self
Marks the variable as read-only.
Sourcepub const fn unset_readonly(&mut self) -> Result<&mut Self, Error>
pub const fn unset_readonly(&mut self) -> Result<&mut Self, Error>
Marks the variable as not read-only.
Sourcepub const fn is_trace_enabled(&self) -> bool
pub const fn is_trace_enabled(&self) -> bool
Returns whether or not the variable is traced.
Sourcepub const fn enable_trace(&mut self) -> &mut Self
pub const fn enable_trace(&mut self) -> &mut Self
Marks the variable as traced.
Sourcepub const fn disable_trace(&mut self) -> &mut Self
pub const fn disable_trace(&mut self) -> &mut Self
Marks the variable as not traced.
Sourcepub const fn is_enumerable(&self) -> bool
pub const fn is_enumerable(&self) -> bool
Returns whether or not the variable should be enumerated in the shell’s environment.
Sourcepub const fn hide_from_enumeration(&mut self) -> &mut Self
pub const fn hide_from_enumeration(&mut self) -> &mut Self
Marks the variable as not enumerable in the shell’s environment.
Sourcepub const fn get_update_transform(&self) -> ShellVariableUpdateTransform
pub const fn get_update_transform(&self) -> ShellVariableUpdateTransform
Return the update transform associated with the variable.
Sourcepub const fn set_update_transform(
&mut self,
transform: ShellVariableUpdateTransform,
)
pub const fn set_update_transform( &mut self, transform: ShellVariableUpdateTransform, )
Set the update transform associated with the variable.
Sourcepub const fn is_treated_as_integer(&self) -> bool
pub const fn is_treated_as_integer(&self) -> bool
Returns whether or not the variable should be treated as an integer.
Sourcepub const fn treat_as_integer(&mut self) -> &mut Self
pub const fn treat_as_integer(&mut self) -> &mut Self
Marks the variable as being treated as an integer.
Sourcepub const fn unset_treat_as_integer(&mut self) -> &mut Self
pub const fn unset_treat_as_integer(&mut self) -> &mut Self
Marks the variable as not being treated as an integer.
Sourcepub const fn is_treated_as_nameref(&self) -> bool
pub const fn is_treated_as_nameref(&self) -> bool
Returns whether or not the variable should be treated as a name reference.
Sourcepub const fn treat_as_nameref(&mut self) -> &mut Self
pub const fn treat_as_nameref(&mut self) -> &mut Self
Marks the variable as being treated as a name reference.
Sourcepub const fn unset_treat_as_nameref(&mut self) -> &mut Self
pub const fn unset_treat_as_nameref(&mut self) -> &mut Self
Marks the variable as not being treated as a name reference.
Sourcepub fn convert_to_indexed_array(&mut self) -> Result<(), Error>
pub fn convert_to_indexed_array(&mut self) -> Result<(), Error>
Converts the variable to an indexed array.
Sourcepub fn convert_to_associative_array(&mut self) -> Result<(), Error>
pub fn convert_to_associative_array(&mut self) -> Result<(), Error>
Converts the variable to an associative array.
Sourcepub fn assign(
&mut self,
value: ShellValueLiteral,
append: bool,
) -> Result<(), Error>
pub fn assign( &mut self, value: ShellValueLiteral, append: bool, ) -> Result<(), Error>
Assign the given value to the variable, conditionally appending to the preexisting value.
§Arguments
value
- The value to assign to the variable.append
- Whether or not to append the value to the preexisting value.
Sourcepub fn assign_at_index(
&mut self,
array_index: String,
value: String,
append: bool,
) -> Result<(), Error>
pub fn assign_at_index( &mut self, array_index: String, value: String, append: bool, ) -> Result<(), Error>
Assign the given value to the variable at the given index, conditionally appending to the preexisting value present at that element within the value.
§Arguments
array_index
- The index at which to assign the value.value
- The value to assign to the variable at the given index.append
- Whether or not to append the value to the preexisting value stored at the given index.
Sourcepub fn unset_index(&mut self, index: &str) -> Result<bool, Error>
pub fn unset_index(&mut self, index: &str) -> Result<bool, Error>
Tries to unset the value stored at the given index in the variable. Returns whether or not a value was unset.
§Arguments
index
- The index at which to unset the value.
Sourcepub fn get_attribute_flags(&self, shell: &Shell) -> String
pub fn get_attribute_flags(&self, shell: &Shell) -> String
Returns the canonical attribute flag string for this variable.
Trait Implementations§
Source§impl Clone for ShellVariable
impl Clone for ShellVariable
Source§fn clone(&self) -> ShellVariable
fn clone(&self) -> ShellVariable
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ShellVariable
impl Debug for ShellVariable
Auto Trait Implementations§
impl Freeze for ShellVariable
impl RefUnwindSafe for ShellVariable
impl Send for ShellVariable
impl Sync for ShellVariable
impl Unpin for ShellVariable
impl UnwindSafe for ShellVariable
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
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>
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>
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