pub struct BashExecutor { /* private fields */ }Expand description
Bash executor with sandboxing
Implementations§
Source§impl BashExecutor
impl BashExecutor
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new bash executor with default sandbox
§Example
use composio_sdk::meta_tools::BashExecutor;
let executor = BashExecutor::new();
let result = executor.execute("ls -la").await?;
println!("Output: {}", result.stdout);Sourcepub fn with_sandbox(sandbox_dir: PathBuf) -> Self
pub fn with_sandbox(sandbox_dir: PathBuf) -> Self
Sourcepub async fn execute(&self, command: &str) -> Result<BashResult, ComposioError>
pub async fn execute(&self, command: &str) -> Result<BashResult, ComposioError>
Execute a bash command
§Arguments
command- Bash command to execute
§Returns
Bash execution result with stdout, stderr, and exit code
§Example
let executor = BashExecutor::new();
let result = executor.execute("echo 'Hello, World!'").await?;
println!("Output: {}", result.stdout);
println!("Exit code: {}", result.exit_code);Sourcepub async fn execute_batch(
&self,
commands: Vec<&str>,
) -> Result<Vec<BashResult>, ComposioError>
pub async fn execute_batch( &self, commands: Vec<&str>, ) -> Result<Vec<BashResult>, ComposioError>
Execute multiple commands sequentially
§Arguments
commands- Vector of bash commands
§Returns
Vector of bash results (one per command)
§Example
let executor = BashExecutor::new();
let results = executor.execute_batch(vec![
"echo 'Step 1'",
"echo 'Step 2'",
"echo 'Step 3'",
]).await?;
for (i, result) in results.iter().enumerate() {
println!("Command {}: {}", i + 1, result.stdout);
}Sourcepub fn sandbox_dir(&self) -> &PathBuf
pub fn sandbox_dir(&self) -> &PathBuf
Get sandbox directory path
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BashExecutor
impl RefUnwindSafe for BashExecutor
impl Send for BashExecutor
impl Sync for BashExecutor
impl Unpin for BashExecutor
impl UnsafeUnpin for BashExecutor
impl UnwindSafe for BashExecutor
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