pub struct InMemoryExecutionEnv { /* private fields */ }Expand description
In-memory ExecutionEnv. Clone shares the underlying state (cheap — the
Arc<Mutex<Inner>> is shared).
Implementations§
Source§impl InMemoryExecutionEnv
impl InMemoryExecutionEnv
pub fn new() -> Self
pub fn with_cwd(cwd: PathBuf) -> Self
Sourcepub async fn register_shell(
&self,
prefix: impl Into<String>,
script: ShellScript,
)
pub async fn register_shell( &self, prefix: impl Into<String>, script: ShellScript, )
Register a canned shell result for commands whose start matches prefix.
Longest-prefix match wins. Mirrors the faux-provider script pattern.
Trait Implementations§
Source§impl Clone for InMemoryExecutionEnv
impl Clone for InMemoryExecutionEnv
Source§fn clone(&self) -> InMemoryExecutionEnv
fn clone(&self) -> InMemoryExecutionEnv
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for InMemoryExecutionEnv
impl Default for InMemoryExecutionEnv
impl ExecutionEnv for InMemoryExecutionEnv
Source§impl FileSystem for InMemoryExecutionEnv
impl FileSystem for InMemoryExecutionEnv
Source§fn absolute_path<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn absolute_path<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Resolve
path (relative-to-cwd, ~, file://, absolute) to an absolute
addressed path. Pure — no FS access, no abort. Mirrors TS absolutePath.Source§fn join_path<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
parts: &'life1 [&'life2 str],
cancel: Option<&'life3 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn join_path<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
parts: &'life1 [&'life2 str],
cancel: Option<&'life3 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Join path components. Pure. Mirrors TS
joinPath.fn read_text_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<String, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn read_text_lines<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
max_lines: Option<usize>,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn read_text_lines<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
max_lines: Option<usize>,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Stream-read up to
max_lines lines (split on \n; max_lines <= 0
→ empty). Mirrors TS readTextLines{maxLines}.fn read_binary_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn write_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
content: FileContent,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn write_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
content: FileContent,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Creates parent directories (recursive) automatically. Mirrors TS
writeFile.fn append_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
content: FileContent,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn rename_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
source: &'life1 str,
dest: &'life2 str,
cancel: Option<&'life3 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn file_info<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<FileInfo, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn file_info<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<FileInfo, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Uses
symlink_metadata (lstat — symlinks not followed). Mirrors TS
fileInfo.fn list_dir<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Vec<FileInfo>, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn canonical_path<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn canonical_path<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Follows symlinks (
canonicalize). Mirrors TS canonicalPath. Backends
may return not_found or not_supported for missing/unsupported paths;
callers (mutation queue) fall back to absolute path on those codes.Source§fn exists<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<bool, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn exists<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<bool, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
false ONLY for not_found; other errors propagate. Mirrors TS
exists (which delegates to fileInfo, NOT access(F_OK)).Source§fn create_dir<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
recursive: bool,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn create_dir<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
recursive: bool,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Default
recursive=true. Mirrors TS createDir{recursive}.Source§fn remove<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
recursive: bool,
force: bool,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn remove<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
recursive: bool,
force: bool,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Defaults
recursive=false, force=false. Mirrors TS remove.Source§fn create_temp_dir<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
prefix: Option<&'life1 str>,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn create_temp_dir<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
prefix: Option<&'life1 str>,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Default prefix
"tmp-". Mirrors TS createTempDir{prefix}.Source§fn create_temp_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
suffix: &'life2 str,
cancel: Option<&'life3 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn create_temp_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
suffix: &'life2 str,
cancel: Option<&'life3 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Mirrors TS
createTempFile{prefix,suffix} (defaults empty). Note: the
TS impl creates an isolated temp dir per file; backends may simplify
to a single file in the OS temp dir (document any divergence).Source§impl MutatingEnv for InMemoryExecutionEnv
impl MutatingEnv for InMemoryExecutionEnv
Source§fn as_env(&self) -> &dyn ExecutionEnv
fn as_env(&self) -> &dyn ExecutionEnv
The underlying
ExecutionEnv (for FileSystem/Shell calls).Source§fn mutation_registry(&self) -> &MutationQueueRegistry
fn mutation_registry(&self) -> &MutationQueueRegistry
The registry holding per-canonical-path mutexes.
Source§impl Shell for InMemoryExecutionEnv
impl Shell for InMemoryExecutionEnv
Source§fn exec<'a, 'life0, 'async_trait>(
&'a self,
command: &'life0 str,
options: ShellExecOptions<'a>,
) -> Pin<Box<dyn Future<Output = Result<ShellOutput, ExecutionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn exec<'a, 'life0, 'async_trait>(
&'a self,
command: &'life0 str,
options: ShellExecOptions<'a>,
) -> Pin<Box<dyn Future<Output = Result<ShellOutput, ExecutionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Execute
command in a bash shell. The TS env resolves a bash binary
(git-bash on Windows, /bin/bash on POSIX, /bin/sh fallback on POSIX).
There is NO cmd.exe fallback on Windows — failure to find bash is
ExecutionError::ShellUnavailable.Auto Trait Implementations§
impl !RefUnwindSafe for InMemoryExecutionEnv
impl !UnwindSafe for InMemoryExecutionEnv
impl Freeze for InMemoryExecutionEnv
impl Send for InMemoryExecutionEnv
impl Sync for InMemoryExecutionEnv
impl Unpin for InMemoryExecutionEnv
impl UnsafeUnpin for InMemoryExecutionEnv
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