pub struct Env<A, FM, L, V, EX, WD, B, N: Eq + Hash, ERR> { /* private fields */ }Expand description
A shell environment implementation which delegates work to other environment implementations.
Implementations§
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> Env<A, FM, L, V, EX, WD, B, N, ERR>
Sourcepub fn with_config(cfg: EnvConfig<A, FM, L, V, EX, WD, B, N, ERR>) -> Self
pub fn with_config(cfg: EnvConfig<A, FM, L, V, EX, WD, B, N, ERR>) -> Self
Creates an environment using the provided configuration of subcomponents.
See EnvConfig for the kinds of overrides possible. DefaultEnvConfig
comes with provided implementations to get you up and running.
General recommendations:
- The result of evaluating a shell word will often be copied and reused
in many different places. It’s strongly recommened that an
Arcwrapper (e.g.Arc<String>) is used to minimize having to reallocate and copy the same data. - Whatever type represents a shell function body needs to be cloned to
get around borrow restrictions and potential recursive executions and
(re-)definitions. Since this type is probably an AST (which may be
arbitrarily large),
Arcis your friend.
Source§impl<T> Env<ArgsEnv<T>, TokioFileDescManagerEnv, LastStatusEnv, VarEnv<T, T>, TokioExecEnv, VirtualWorkingDirEnv, BuiltinEnv<T>, T, RuntimeError>where
T: StringWrapper,
impl<T> Env<ArgsEnv<T>, TokioFileDescManagerEnv, LastStatusEnv, VarEnv<T, T>, TokioExecEnv, VirtualWorkingDirEnv, BuiltinEnv<T>, T, RuntimeError>where
T: StringWrapper,
Trait Implementations§
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> ArgumentsEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> ArgumentsEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
Source§type Arg = <A as ArgumentsEnvironment>::Arg
type Arg = <A as ArgumentsEnvironment>::Arg
The type of arguments this environment holds.
Source§fn arg(&self, idx: usize) -> Option<&Self::Arg>
fn arg(&self, idx: usize) -> Option<&Self::Arg>
Get an argument at any index. Arguments are 1-indexed since the shell variable
$0
refers to the shell’s name. Thus the first real argument starts at index 1.Source§impl<A, FM, L, V, EX, WD, B, N, ERR> AsyncIoEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> AsyncIoEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
Source§type IoHandle = <FM as AsyncIoEnvironment>::IoHandle
type IoHandle = <FM as AsyncIoEnvironment>::IoHandle
The underlying handle (e.g.
FileDesc) with which to perform the async I/O.Source§fn read_all(
&mut self,
fd: Self::IoHandle,
) -> BoxFuture<'static, Result<Vec<u8>>>
fn read_all( &mut self, fd: Self::IoHandle, ) -> BoxFuture<'static, Result<Vec<u8>>>
Asynchronously read all data from the specified handle.
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> BuiltinEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> BuiltinEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
Source§type BuiltinName = <B as BuiltinEnvironment>::BuiltinName
type BuiltinName = <B as BuiltinEnvironment>::BuiltinName
The name for looking up a builtin utility.
Source§type Builtin = <B as BuiltinEnvironment>::Builtin
type Builtin = <B as BuiltinEnvironment>::Builtin
The type of the builtin utility.
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> ChangeWorkingDirectoryEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>where
N: Hash + Eq,
V: VariableEnvironment,
V::VarName: From<String>,
V::Var: From<String>,
WD: WorkingDirectoryEnvironment + ChangeWorkingDirectoryEnvironment,
impl<A, FM, L, V, EX, WD, B, N, ERR> ChangeWorkingDirectoryEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>where
N: Hash + Eq,
V: VariableEnvironment,
V::VarName: From<String>,
V::Var: From<String>,
WD: WorkingDirectoryEnvironment + ChangeWorkingDirectoryEnvironment,
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> ExecutableEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> ExecutableEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
Source§fn spawn_executable(
&self,
data: ExecutableData<'_>,
) -> Result<BoxFuture<'static, ExitStatus>, CommandError>
fn spawn_executable( &self, data: ExecutableData<'_>, ) -> Result<BoxFuture<'static, ExitStatus>, CommandError>
Attempt to spawn the executable command.
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> ExportedVariableEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> ExportedVariableEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> FileDescEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> FileDescEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
Source§type FileHandle = <FM as FileDescEnvironment>::FileHandle
type FileHandle = <FM as FileDescEnvironment>::FileHandle
A file handle (or wrapper) to associate with shell file descriptors.
Source§fn file_desc(&self, fd: Fd) -> Option<(&Self::FileHandle, Permissions)>
fn file_desc(&self, fd: Fd) -> Option<(&Self::FileHandle, Permissions)>
Get the permissions and a handle associated with an opened file descriptor.
Source§fn set_file_desc(&mut self, fd: Fd, fdes: Self::FileHandle, perms: Permissions)
fn set_file_desc(&mut self, fd: Fd, fdes: Self::FileHandle, perms: Permissions)
Associate a file descriptor with a given handle and permissions.
Source§fn close_file_desc(&mut self, fd: Fd)
fn close_file_desc(&mut self, fd: Fd)
Treat the specified file descriptor as closed for the current environment.
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> FileDescOpener for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> FileDescOpener for Env<A, FM, L, V, EX, WD, B, N, ERR>
Source§type OpenedFileHandle = <FM as FileDescOpener>::OpenedFileHandle
type OpenedFileHandle = <FM as FileDescOpener>::OpenedFileHandle
A type which represents an opened file descriptor.
Source§fn open_path(
&mut self,
path: &Path,
opts: &OpenOptions,
) -> Result<Self::OpenedFileHandle>
fn open_path( &mut self, path: &Path, opts: &OpenOptions, ) -> Result<Self::OpenedFileHandle>
Open a provided
path with the specified OpenOptions.Source§impl<A, FM, L, V, EX, WD, B, N, ERR> From<EnvConfig<A, FM, L, V, EX, WD, B, N, ERR>> for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> From<EnvConfig<A, FM, L, V, EX, WD, B, N, ERR>> for Env<A, FM, L, V, EX, WD, B, N, ERR>
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> FunctionEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> FunctionEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
Source§type Fn = Arc<dyn Spawn<Env<A, FM, L, V, EX, WD, B, N, ERR>, Error = ERR> + Send + Sync>
type Fn = Arc<dyn Spawn<Env<A, FM, L, V, EX, WD, B, N, ERR>, Error = ERR> + Send + Sync>
The type of the function.
Source§fn function(&self, name: &Self::FnName) -> Option<&Self::Fn>
fn function(&self, name: &Self::FnName) -> Option<&Self::Fn>
Get a particularly named function if it was registered.
Source§fn set_function(&mut self, name: Self::FnName, func: Self::Fn)
fn set_function(&mut self, name: Self::FnName, func: Self::Fn)
Register a shell function with a given name.
Source§fn has_function(&self, name: &Self::FnName) -> bool
fn has_function(&self, name: &Self::FnName) -> bool
Check if a particularly named function was registered.
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> FunctionFrameEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> FunctionFrameEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
Source§fn push_fn_frame(&mut self)
fn push_fn_frame(&mut self)
Denote that a new function has been invoked and is currently executing.
Source§fn pop_fn_frame(&mut self)
fn pop_fn_frame(&mut self)
Denote that a function has completed and is no longer executing.
Source§fn is_fn_running(&self) -> bool
fn is_fn_running(&self) -> bool
Determines if there is at least one function being currently executed.
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> IsInteractiveEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> IsInteractiveEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
Source§fn is_interactive(&self) -> bool
fn is_interactive(&self) -> bool
Indicates if running in interactive mode.
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> LastStatusEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> LastStatusEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
Source§fn last_status(&self) -> ExitStatus
fn last_status(&self) -> ExitStatus
Get the exit status of the previous command.
Source§fn set_last_status(&mut self, status: ExitStatus)
fn set_last_status(&mut self, status: ExitStatus)
Set the exit status of the previously run command.
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> ReportErrorEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>where
A: ArgumentsEnvironment,
A::Arg: Display,
FM: AsyncIoEnvironment + FileDescEnvironment,
FM::FileHandle: Clone,
FM::IoHandle: From<FM::FileHandle>,
N: Hash + Eq,
impl<A, FM, L, V, EX, WD, B, N, ERR> ReportErrorEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>where
A: ArgumentsEnvironment,
A::Arg: Display,
FM: AsyncIoEnvironment + FileDescEnvironment,
FM::FileHandle: Clone,
FM::IoHandle: From<FM::FileHandle>,
N: Hash + Eq,
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> SetArgumentsEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> SetArgumentsEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> ShiftArgumentsEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> ShiftArgumentsEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
Source§fn shift_args(&mut self, amt: usize)
fn shift_args(&mut self, amt: usize)
Shift parameters such that the positional parameter
n will hold
the value of the positional parameter n + amt. Read moreSource§impl<A, FM, L, V, EX, WD, B, N, ERR> SubEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>where
A: SubEnvironment,
FM: SubEnvironment,
L: SubEnvironment,
V: SubEnvironment,
B: SubEnvironment,
N: Hash + Eq,
EX: SubEnvironment,
WD: SubEnvironment,
impl<A, FM, L, V, EX, WD, B, N, ERR> SubEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>where
A: SubEnvironment,
FM: SubEnvironment,
L: SubEnvironment,
V: SubEnvironment,
B: SubEnvironment,
N: Hash + Eq,
EX: SubEnvironment,
WD: SubEnvironment,
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> UnsetFunctionEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> UnsetFunctionEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
Source§fn unset_function(&mut self, name: &Self::FnName)
fn unset_function(&mut self, name: &Self::FnName)
Removes the definition of a function if it was registered.
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> UnsetVariableEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> UnsetVariableEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> VariableEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> VariableEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
Source§type VarName = <V as VariableEnvironment>::VarName
type VarName = <V as VariableEnvironment>::VarName
The type of the name this environment associates for a variable.
Source§type Var = <V as VariableEnvironment>::Var
type Var = <V as VariableEnvironment>::Var
The type of variables this environment holds.
Source§fn var<Q>(&self, name: &Q) -> Option<&Self::Var>
fn var<Q>(&self, name: &Q) -> Option<&Self::Var>
Get the value of some variable. The values of both shell-only
and environment variables will be looked up and returned.
Source§impl<A, FM, L, V, EX, WD, B, N, ERR> WorkingDirectoryEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> WorkingDirectoryEnvironment for Env<A, FM, L, V, EX, WD, B, N, ERR>
Auto Trait Implementations§
impl<A, FM, L, V, EX, WD, B, N, ERR> Freeze for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> !RefUnwindSafe for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> Send for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> Sync for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> Unpin for Env<A, FM, L, V, EX, WD, B, N, ERR>
impl<A, FM, L, V, EX, WD, B, N, ERR> !UnwindSafe for Env<A, FM, L, V, EX, WD, B, N, ERR>
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