pub struct JsCodeExecutor<H> { /* private fields */ }Expand description
Adapter bridging [HttpExecutor] to CodeExecutor for JavaScript/OpenAPI
servers (Pattern B: JS+HTTP).
Compiles JavaScript code into an execution plan, then runs it against an
HTTP backend. The executor holds its own [ExecutionConfig] for limits
(max_api_calls, timeout_seconds, max_loop_iterations).
§Example
ⓘ
use pmcp_code_mode::{JsCodeExecutor, ExecutionConfig};
let http = CostExplorerHttpExecutor::new(clients.clone());
let config = ExecutionConfig::default();
let executor = Arc::new(JsCodeExecutor::new(http, config));
// Pass executor to #[derive(CodeMode)] struct as code_executor fieldImplementations§
Source§impl<H: HttpExecutor + Clone> JsCodeExecutor<H>
impl<H: HttpExecutor + Clone> JsCodeExecutor<H>
Sourcepub fn new(http: H, config: ExecutionConfig) -> Self
pub fn new(http: H, config: ExecutionConfig) -> Self
Create a new JS code executor with the given HTTP backend and config.
Trait Implementations§
Source§impl<H: HttpExecutor + Clone + 'static> CodeExecutor for JsCodeExecutor<H>
impl<H: HttpExecutor + Clone + 'static> CodeExecutor for JsCodeExecutor<H>
Source§fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
code: &'life1 str,
variables: Option<&'life2 Value>,
) -> Pin<Box<dyn Future<Output = Result<Value, ExecutionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
code: &'life1 str,
variables: Option<&'life2 Value>,
) -> Pin<Box<dyn Future<Output = Result<Value, ExecutionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute validated code and return the result. Read more
Auto Trait Implementations§
impl<H> Freeze for JsCodeExecutor<H>where
H: Freeze,
impl<H> RefUnwindSafe for JsCodeExecutor<H>where
H: RefUnwindSafe,
impl<H> Send for JsCodeExecutor<H>where
H: Send,
impl<H> Sync for JsCodeExecutor<H>where
H: Sync,
impl<H> Unpin for JsCodeExecutor<H>where
H: Unpin,
impl<H> UnsafeUnpin for JsCodeExecutor<H>where
H: UnsafeUnpin,
impl<H> UnwindSafe for JsCodeExecutor<H>where
H: UnwindSafe,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.