Struct ShellVariable

Source
pub struct ShellVariable { /* private fields */ }
Expand description

A shell variable.

Implementations§

Source§

impl ShellVariable

Source

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.
Source

pub const fn value(&self) -> &ShellValue

Returns the value associated with the variable.

Source

pub const fn is_exported(&self) -> bool

Returns whether or not the variable is exported to child processes.

Source

pub const fn export(&mut self) -> &mut Self

Marks the variable as exported to child processes.

Source

pub const fn unexport(&mut self) -> &mut Self

Marks the variable as not exported to child processes.

Source

pub const fn is_readonly(&self) -> bool

Returns whether or not the variable is read-only.

Source

pub const fn set_readonly(&mut self) -> &mut Self

Marks the variable as read-only.

Source

pub const fn unset_readonly(&mut self) -> Result<&mut Self, Error>

Marks the variable as not read-only.

Source

pub const fn is_trace_enabled(&self) -> bool

Returns whether or not the variable is traced.

Source

pub const fn enable_trace(&mut self) -> &mut Self

Marks the variable as traced.

Source

pub const fn disable_trace(&mut self) -> &mut Self

Marks the variable as not traced.

Source

pub const fn is_enumerable(&self) -> bool

Returns whether or not the variable should be enumerated in the shell’s environment.

Source

pub const fn hide_from_enumeration(&mut self) -> &mut Self

Marks the variable as not enumerable in the shell’s environment.

Source

pub const fn get_update_transform(&self) -> ShellVariableUpdateTransform

Return the update transform associated with the variable.

Source

pub const fn set_update_transform( &mut self, transform: ShellVariableUpdateTransform, )

Set the update transform associated with the variable.

Source

pub const fn is_treated_as_integer(&self) -> bool

Returns whether or not the variable should be treated as an integer.

Source

pub const fn treat_as_integer(&mut self) -> &mut Self

Marks the variable as being treated as an integer.

Source

pub const fn unset_treat_as_integer(&mut self) -> &mut Self

Marks the variable as not being treated as an integer.

Source

pub const fn is_treated_as_nameref(&self) -> bool

Returns whether or not the variable should be treated as a name reference.

Source

pub const fn treat_as_nameref(&mut self) -> &mut Self

Marks the variable as being treated as a name reference.

Source

pub const fn unset_treat_as_nameref(&mut self) -> &mut Self

Marks the variable as not being treated as a name reference.

Source

pub fn convert_to_indexed_array(&mut self) -> Result<(), Error>

Converts the variable to an indexed array.

Source

pub fn convert_to_associative_array(&mut self) -> Result<(), Error>

Converts the variable to an associative array.

Source

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.
Source

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.
Source

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.
Source

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

Source§

fn clone(&self) -> ShellVariable

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ShellVariable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ShellVariable

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more