diff options
| author | Jonas Maier <> | 2026-03-07 09:45:10 +0100 |
|---|---|---|
| committer | Jonas Maier <> | 2026-03-07 09:45:10 +0100 |
| commit | 7bd6e6253268ec626a7191344ce9ff77358f94db (patch) | |
| tree | 350ad68defb46e7babaa0ddb0b44320046ce608d /src/run/mod.rs | |
| parent | f1386f2d7b63c8a215b0d5c8c3fc5bc6c167aa0e (diff) | |
| download | pish-7bd6e6253268ec626a7191344ce9ff77358f94db.tar.gz | |
adjust builtins for new trait
Diffstat (limited to 'src/run/mod.rs')
| -rw-r--r-- | src/run/mod.rs | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/run/mod.rs b/src/run/mod.rs index 8c629b0..a27812f 100644 --- a/src/run/mod.rs +++ b/src/run/mod.rs @@ -256,22 +256,31 @@ pub fn run(se: &mut Session, cmd: Vec<u8>) { let _ = std::io::stdout().lock().flush(); } +#[derive(Debug)] +enum BuiltinError { + IO(std::io::Error), + Exit(i32), +} + +impl From<std::io::Error> for BuiltinError { + fn from(value: std::io::Error) -> Self { + Self::IO(value) + } +} + +type BuiltinResult = Result<(), BuiltinError>; + #[allow(unused_variables)] pub trait Builtin: Send + Sync { fn name(&self) -> &str; - /// quick synchronous call, `cd` for example - fn mod_session(&self, session: &mut Session, args: &[BString]) {} - - /// potentially long, pipelineable thread, builtin `cat` for example fn io( &self, + session: Arc<Mutex<Session>>, args: &[BString], stdin: &mut dyn Read, stdout: &mut dyn Write, - ) -> std::io::Result<()> { - Ok(()) - } + ) -> BuiltinResult; } const BUILTINS: &[&'static dyn Builtin] = &[ |
