pub struct PluginInstance { /* private fields */ }Expand description
A WASM plugin instance ready for execution.
Implementations§
Source§impl PluginInstance
impl PluginInstance
Sourcepub fn new(
engine: &Engine,
module: &CompiledModule,
limits: PluginLimits,
) -> Result<Self, WasmError>
pub fn new( engine: &Engine, module: &CompiledModule, limits: PluginLimits, ) -> Result<Self, WasmError>
Create a new plugin instance from a compiled module.
Sourcepub fn new_with_http_client(
engine: &Engine,
module: &CompiledModule,
limits: PluginLimits,
http_client: Option<Arc<HttpClient>>,
) -> Result<Self, WasmError>
pub fn new_with_http_client( engine: &Engine, module: &CompiledModule, limits: PluginLimits, http_client: Option<Arc<HttpClient>>, ) -> Result<Self, WasmError>
Create a new plugin instance with an HTTP client for outbound calls.
Sourcepub fn new_with_options(
engine: &Engine,
module: &CompiledModule,
limits: PluginLimits,
http_client: Option<Arc<HttpClient>>,
secrets: Option<SecretsStore>,
) -> Result<Self, WasmError>
pub fn new_with_options( engine: &Engine, module: &CompiledModule, limits: PluginLimits, http_client: Option<Arc<HttpClient>>, secrets: Option<SecretsStore>, ) -> Result<Self, WasmError>
Create a new plugin instance with HTTP client and secrets.
Sourcepub fn new_with_all_options(
engine: &Engine,
module: &CompiledModule,
limits: PluginLimits,
http_client: Option<Arc<HttpClient>>,
secrets: Option<SecretsStore>,
rate_limiter: Option<RateLimiter>,
response_cache: Option<ResponseCache>,
nats_publisher: Option<Arc<NatsPublisher>>,
kafka_publisher: Option<Arc<KafkaPublisher>>,
) -> Result<Self, WasmError>
pub fn new_with_all_options( engine: &Engine, module: &CompiledModule, limits: PluginLimits, http_client: Option<Arc<HttpClient>>, secrets: Option<SecretsStore>, rate_limiter: Option<RateLimiter>, response_cache: Option<ResponseCache>, nats_publisher: Option<Arc<NatsPublisher>>, kafka_publisher: Option<Arc<KafkaPublisher>>, ) -> Result<Self, WasmError>
Create a new plugin instance with all options including rate limiter and cache.
Sourcepub fn write_to_memory(&mut self, data: &[u8]) -> Result<i32, WasmError>
pub fn write_to_memory(&mut self, data: &[u8]) -> Result<i32, WasmError>
Write data to the plugin’s linear memory and return the pointer.
Uses the plugin’s exported alloc function so that dlmalloc is aware
of the allocation and will not reuse the region during deserialization.
Falls back to growing memory directly for legacy plugins that lack the
alloc export (only safe for very small payloads like config JSON).
Sourcepub fn init(&mut self, config_json: &[u8]) -> Result<i32, WasmError>
pub fn init(&mut self, config_json: &[u8]) -> Result<i32, WasmError>
Call the init function with the given config.
Sourcepub fn on_request(&mut self, request_json: &[u8]) -> Result<i32, WasmError>
pub fn on_request(&mut self, request_json: &[u8]) -> Result<i32, WasmError>
Call on_request with the given request data.
Sourcepub fn on_response(&mut self, response_json: &[u8]) -> Result<i32, WasmError>
pub fn on_response(&mut self, response_json: &[u8]) -> Result<i32, WasmError>
Call on_response with the given response data.
Sourcepub fn dispatch(&mut self, request_json: &[u8]) -> Result<i32, WasmError>
pub fn dispatch(&mut self, request_json: &[u8]) -> Result<i32, WasmError>
Call dispatch with the given request data.
Sourcepub fn take_output(&mut self) -> Vec<u8> ⓘ
pub fn take_output(&mut self) -> Vec<u8> ⓘ
Get the output buffer contents.
Sourcepub fn set_context(&mut self, context: RequestContext)
pub fn set_context(&mut self, context: RequestContext)
Set the request context for the next call.
Sourcepub fn get_context(&self) -> RequestContext
pub fn get_context(&self) -> RequestContext
Get the current request context (after modifications by host functions).
Sourcepub fn take_last_http_result(&mut self) -> Option<Vec<u8>>
pub fn take_last_http_result(&mut self) -> Option<Vec<u8>>
Take the last HTTP result buffer (from host_http_call or host_http_stream).
Returns None if no HTTP call was made or the result was already taken.
Sourcepub fn set_stream_sender(&mut self, sender: Arc<UnboundedSender<StreamEvent>>)
pub fn set_stream_sender(&mut self, sender: Arc<UnboundedSender<StreamEvent>>)
Inject a stream sender for host_http_stream before calling dispatch.
The sender is wrapped in an Arc so host functions can clone it for
use inside std::thread::scope without lifetime conflicts.
Sourcepub fn take_ws_upgrade_request(&mut self) -> Option<WsUpgradeRequest>
pub fn take_ws_upgrade_request(&mut self) -> Option<WsUpgradeRequest>
Take the upstream WebSocket upgrade request from host_ws_upgrade (ADR-0026).
Returns None if no WebSocket upgrade was requested or the request
was already taken.
Sourcepub fn set_request_body(&mut self, body: Option<Vec<u8>>)
pub fn set_request_body(&mut self, body: Option<Vec<u8>>)
Set the request/response body for the next handler call (side-channel).
Auto Trait Implementations§
impl Freeze for PluginInstance
impl !RefUnwindSafe for PluginInstance
impl Send for PluginInstance
impl Sync for PluginInstance
impl Unpin for PluginInstance
impl UnsafeUnpin for PluginInstance
impl !UnwindSafe for PluginInstance
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request