Skip to main content

BashHost

Trait BashHost 

Source
pub trait BashHost {
    // Required method
    fn fs(&self) -> &dyn Filesystem;

    // Provided method
    fn run_builtin<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 mut self,
        cwd: &'life1 str,
        cmd: &'life2 str,
        args: &'life3 [String],
        stdin: &'life4 str,
    ) -> Pin<Box<dyn Future<Output = Output> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait { ... }
}
Expand description

The capabilities bashlite eval needs from its environment.

async_trait(?Send) on EVERY target: the bashlite evaluator’s recursion futures are boxed-local (non-Send), and the interpreter is inherently single-threaded — it’s awaited directly (CLI/tests) or run on the browser’s single-threaded executor, never spawned across threads. A Send bound here would force H: Send through the whole evaluator for no benefit.

Required Methods§

Source

fn fs(&self) -> &dyn Filesystem

The sandbox filesystem the fs builtins operate over (OPFS in-browser, Native on the CLI, an in-memory map in tests).

Provided Methods§

Source

fn run_builtin<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, cwd: &'life1 str, cmd: &'life2 str, args: &'life3 [String], stdin: &'life4 str, ) -> Pin<Box<dyn Future<Output = Output> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Run a command by name with already-expanded args, the caller’s current directory cwd, and piped stdin. The default impl dispatches the v1 fs builtins (crate::bashlite::builtins). A host OVERRIDES this to add commands — e.g. the lh-* platform reads (crate::bashlite::platform) — delegating to dispatch_in for anything it doesn’t own. This is the extension seam: the evaluator routes every non-control command through it.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§