pub struct RustExecutor { /* private fields */ }Expand description
Rust-specific executor that compiles code through a check → build → execute pipeline
and delegates execution to a SandboxBackend.
§Example
ⓘ
use adk_code::{RustExecutor, RustExecutorConfig};
use adk_sandbox::ProcessBackend;
use std::sync::Arc;
let backend = Arc::new(ProcessBackend::default());
let executor = RustExecutor::new(backend, RustExecutorConfig::default());
let result = executor.execute("fn run(input: serde_json::Value) -> serde_json::Value { input }", None).await?;Implementations§
Source§impl RustExecutor
impl RustExecutor
Sourcepub fn new(backend: Arc<dyn SandboxBackend>, config: RustExecutorConfig) -> Self
pub fn new(backend: Arc<dyn SandboxBackend>, config: RustExecutorConfig) -> Self
Create a new executor with the given sandbox backend and configuration.
Sourcepub async fn execute(
&self,
code: &str,
input: Option<&Value>,
timeout: Duration,
) -> Result<CodeResult, CodeError>
pub async fn execute( &self, code: &str, input: Option<&Value>, timeout: Duration, ) -> Result<CodeResult, CodeError>
Execute Rust code through the check → build → execute pipeline.
The input parameter is optional JSON that will be serialized to stdin
for the harness run() function.
§Errors
CodeError::InvalidCodeif the source fails pre-compilation validationCodeError::CompileErrorif the check step finds error-level diagnosticsCodeError::DependencyNotFoundifserde_jsoncannot be locatedCodeError::Sandboxif the backend fails during execution
Auto Trait Implementations§
impl Freeze for RustExecutor
impl !RefUnwindSafe for RustExecutor
impl Send for RustExecutor
impl Sync for RustExecutor
impl Unpin for RustExecutor
impl UnsafeUnpin for RustExecutor
impl !UnwindSafe for RustExecutor
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