Skip to main content

RustExecutor

Struct RustExecutor 

Source
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.

§Isolation

StepWhere it runsEnvironment
Check, buildInside the backend when it confines filesystem reads and accepts Language::Command (Unix only); otherwise on the hostCleared, plus the toolchain allowlist from ProcessBackend::toolchain_env
ExecuteInside the backendWhatever the backend exposes; ProcessBackend clears it

With the environment cleared, env! and option_env! in user code cannot embed host credentials into the binary. Compile-time file access such as include_str! reads with the permissions of wherever rustc runs: inside a read-confining backend it is confined like the binary, and on the host it reaches no file the binary could not also read at run time, because rustc runs on the host only when the backend does not confine reads. On Windows, rustc always runs on the host.

§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

Source

pub fn new(backend: Arc<dyn SandboxBackend>, config: RustExecutorConfig) -> Self

Create a new executor with the given sandbox backend and configuration.

Source

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more