Skip to main content

PluginContext

Struct PluginContext 

Source
pub struct PluginContext<'a> { /* private fields */ }
Expand description

Borrowed safe wrapper around a host plugin registration context.

Implementations§

Source§

impl<'a> PluginContext<'a>

Source

pub unsafe fn from_raw( host: &'a NemoRelayNativeHostApiV1, raw: *mut NemoRelayNativePluginContext, ) -> Self

Creates a plugin context wrapper from raw ABI parts.

§Safety

host and raw must remain valid for the lifetime of this wrapper.

Source

pub fn host_api(&self) -> &'a NemoRelayNativeHostApiV1

Returns the host ABI table backing this registration context.

Source

pub fn runtime(&self) -> PluginRuntime

Returns a cloneable high-level runtime handle.

Source

pub fn register_subscriber<F>(&mut self, name: &str, callback: F) -> Result<()>
where F: Fn(&Event) + Send + Sync + 'static,

Registers a typed event subscriber callback.

Source

pub fn register_mark_sanitize_guardrail<F>( &mut self, name: &str, priority: i32, callback: F, ) -> Result<()>

Registers a typed mark event sanitizer.

Source

pub fn register_scope_sanitize_start_guardrail<F>( &mut self, name: &str, priority: i32, callback: F, ) -> Result<()>

Registers a typed scope-start event sanitizer.

Source

pub fn register_scope_sanitize_end_guardrail<F>( &mut self, name: &str, priority: i32, callback: F, ) -> Result<()>

Registers a typed scope-end event sanitizer.

Source

pub fn register_tool_sanitize_request_guardrail<F>( &mut self, name: &str, priority: i32, callback: F, ) -> Result<()>
where F: Fn(&str, Json) -> Json + Send + Sync + 'static,

Registers a typed tool sanitize-request guardrail.

Source

pub fn register_tool_sanitize_response_guardrail<F>( &mut self, name: &str, priority: i32, callback: F, ) -> Result<()>
where F: Fn(&str, Json) -> Json + Send + Sync + 'static,

Registers a typed tool sanitize-response guardrail.

Source

pub fn register_tool_conditional_execution_guardrail<F>( &mut self, name: &str, priority: i32, callback: F, ) -> Result<()>
where F: Fn(&str, &Json) -> Result<Option<String>> + Send + Sync + 'static,

Registers a typed tool conditional-execution guardrail.

Source

pub fn register_tool_request_intercept<F>( &mut self, name: &str, priority: i32, break_chain: bool, callback: F, ) -> Result<()>
where F: Fn(&str, Json) -> Result<Json> + Send + Sync + 'static,

Registers a typed tool request intercept.

Source

pub fn register_tool_execution_intercept<F>( &mut self, name: &str, priority: i32, callback: F, ) -> Result<()>
where F: for<'next> Fn(&str, Json, ToolNext<'next>) -> Result<ToolExecutionInterceptOutcome> + Send + Sync + 'static,

Registers a typed tool execution intercept.

The callback returns a ToolExecutionInterceptOutcome. Calling ToolNext::call continues the chain and returns only the raw downstream result JSON; Relay retains downstream pending marks.

Source

pub fn register_llm_sanitize_request_guardrail<F>( &mut self, name: &str, priority: i32, callback: F, ) -> Result<()>
where F: for<'ctx> Fn(LlmRequest, LlmSanitizeRequestContext<'ctx>) -> Option<LlmRequest> + Send + Sync + 'static,

Registers a typed LLM sanitize-request guardrail.

Source

pub fn register_llm_sanitize_response_guardrail<F>( &mut self, name: &str, priority: i32, callback: F, ) -> Result<()>
where F: for<'ctx> Fn(Json, LlmSanitizeResponseContext<'ctx>) -> Option<Json> + Send + Sync + 'static,

Registers a typed LLM sanitize-response guardrail.

Source

pub fn register_llm_conditional_execution_guardrail<F>( &mut self, name: &str, priority: i32, callback: F, ) -> Result<()>
where F: Fn(&LlmRequest) -> Result<Option<String>> + Send + Sync + 'static,

Registers a typed LLM conditional-execution guardrail.

Source

pub fn register_llm_request_intercept<F>( &mut self, name: &str, priority: i32, break_chain: bool, callback: F, ) -> Result<()>

Registers a typed LLM request intercept.

Source

pub fn register_llm_execution_intercept<F>( &mut self, name: &str, priority: i32, callback: F, ) -> Result<()>
where F: for<'next> Fn(&str, LlmRequest, LlmNext<'next>) -> Result<Json> + Send + Sync + 'static,

Registers a typed LLM execution intercept.

Source

pub fn register_llm_stream_execution_intercept<F>( &mut self, name: &str, priority: i32, callback: F, ) -> Result<()>
where F: for<'next> Fn(&str, LlmRequest, LlmStreamNext<'next>) -> Result<LlmJsonStream> + Send + Sync + 'static,

Registers a typed LLM stream execution intercept.

Native ABI v2 represents stream execution as one JSON result. The host wraps that result as a one-chunk stream.

Source

pub unsafe fn register_subscriber_raw( &mut self, name: &str, cb: NemoRelayNativeEventSubscriberCb, user_data: *mut c_void, free_fn: NemoRelayNativeFreeFn, ) -> NemoRelayStatus

Registers a raw event subscriber callback.

§Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

Source

pub unsafe fn register_mark_sanitize_guardrail_raw( &mut self, name: &str, priority: i32, cb: NemoRelayNativeEventSanitizeCb, user_data: *mut c_void, free_fn: NemoRelayNativeFreeFn, ) -> NemoRelayStatus

Registers a raw mark event sanitizer callback.

§Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

Source

pub unsafe fn register_scope_sanitize_start_guardrail_raw( &mut self, name: &str, priority: i32, cb: NemoRelayNativeEventSanitizeCb, user_data: *mut c_void, free_fn: NemoRelayNativeFreeFn, ) -> NemoRelayStatus

Registers a raw scope-start event sanitizer callback.

§Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

Source

pub unsafe fn register_scope_sanitize_end_guardrail_raw( &mut self, name: &str, priority: i32, cb: NemoRelayNativeEventSanitizeCb, user_data: *mut c_void, free_fn: NemoRelayNativeFreeFn, ) -> NemoRelayStatus

Registers a raw scope-end event sanitizer callback.

§Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

Source

pub unsafe fn register_tool_sanitize_request_guardrail_raw( &mut self, name: &str, priority: i32, cb: NemoRelayNativeToolJsonCb, user_data: *mut c_void, free_fn: NemoRelayNativeFreeFn, ) -> NemoRelayStatus

Registers a raw tool sanitize-request guardrail callback.

§Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

Source

pub unsafe fn register_tool_sanitize_response_guardrail_raw( &mut self, name: &str, priority: i32, cb: NemoRelayNativeToolJsonCb, user_data: *mut c_void, free_fn: NemoRelayNativeFreeFn, ) -> NemoRelayStatus

Registers a raw tool sanitize-response guardrail callback.

§Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

Source

pub unsafe fn register_tool_conditional_execution_guardrail_raw( &mut self, name: &str, priority: i32, cb: NemoRelayNativeToolConditionalCb, user_data: *mut c_void, free_fn: NemoRelayNativeFreeFn, ) -> NemoRelayStatus

Registers a raw tool conditional-execution guardrail callback.

§Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

Source

pub unsafe fn register_tool_request_intercept_raw( &mut self, name: &str, priority: i32, break_chain: bool, cb: NemoRelayNativeToolJsonCb, user_data: *mut c_void, free_fn: NemoRelayNativeFreeFn, ) -> NemoRelayStatus

Registers a raw tool request intercept callback.

§Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

Source

pub unsafe fn register_tool_execution_intercept_raw( &mut self, name: &str, priority: i32, cb: NemoRelayNativeToolExecutionCb, user_data: *mut c_void, free_fn: NemoRelayNativeFreeFn, ) -> NemoRelayStatus

Registers a raw tool execution intercept callback.

§Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

Source

pub unsafe fn register_llm_sanitize_request_guardrail_raw( &mut self, name: &str, priority: i32, cb: NemoRelayNativeLlmSanitizeRequestCb, user_data: *mut c_void, free_fn: NemoRelayNativeFreeFn, ) -> NemoRelayStatus

Registers a raw LLM sanitize-request guardrail callback.

§Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

Source

pub unsafe fn register_llm_sanitize_response_guardrail_raw( &mut self, name: &str, priority: i32, cb: NemoRelayNativeLlmSanitizeResponseCb, user_data: *mut c_void, free_fn: NemoRelayNativeFreeFn, ) -> NemoRelayStatus

Registers a raw LLM sanitize-response guardrail callback.

§Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

Source

pub unsafe fn register_llm_conditional_execution_guardrail_raw( &mut self, name: &str, priority: i32, cb: NemoRelayNativeLlmConditionalCb, user_data: *mut c_void, free_fn: NemoRelayNativeFreeFn, ) -> NemoRelayStatus

Registers a raw LLM conditional-execution guardrail callback.

§Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

Source

pub unsafe fn register_llm_request_intercept_raw( &mut self, name: &str, priority: i32, break_chain: bool, cb: NemoRelayNativeLlmRequestInterceptCb, user_data: *mut c_void, free_fn: NemoRelayNativeFreeFn, ) -> NemoRelayStatus

Registers a raw LLM request intercept callback.

§Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

Source

pub unsafe fn register_llm_execution_intercept_raw( &mut self, name: &str, priority: i32, cb: NemoRelayNativeLlmExecutionCb, user_data: *mut c_void, free_fn: NemoRelayNativeFreeFn, ) -> NemoRelayStatus

Registers a raw LLM execution intercept callback.

§Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

Source

pub unsafe fn register_llm_stream_execution_intercept_raw( &mut self, name: &str, priority: i32, cb: NemoRelayNativeLlmStreamExecutionCb, user_data: *mut c_void, free_fn: NemoRelayNativeFreeFn, ) -> NemoRelayStatus

Registers a raw LLM stream execution intercept callback.

§Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

Source

pub unsafe fn register_async_middleware_raw( &mut self, kind: NemoRelayNativeAsyncMiddlewareKind, name: &str, priority: i32, break_chain: bool, cb: NemoRelayNativeAsyncMiddlewareCb, user_data: *mut c_void, free_fn: NemoRelayNativeFreeFn, ) -> NemoRelayStatus

Registers completion-based asynchronous middleware through the ABI-v3 extension table.

Plugins built against older hosts receive NemoRelayStatus::InvalidArg instead of attempting to read beyond the legacy host table.

§Safety

cb, user_data, and free_fn must remain valid until the host deregisters the callback or invokes free_fn. A callback returning Pending must settle and release its completion/next references. NemoRelayNativeAsyncMiddlewareKind::LlmStreamExecutionIntercept is rejected; use Self::register_async_stream_middleware_raw instead.

Source

pub unsafe fn register_async_stream_middleware_raw( &mut self, name: &str, priority: i32, cb: NemoRelayNativeAsyncStreamMiddlewareCb, user_data: *mut c_void, free_fn: NemoRelayNativeFreeFn, ) -> NemoRelayStatus

Registers an incremental completion-based LLM stream intercept.

§Safety

The callback and user data must remain valid until deregistration or free_fn; callback-owned next and stream handles must each be released exactly once. Stream pushes and rejection are nonblocking: Internal with a host last-error containing backpressured means the bounded queue is full and the operation may be retried. The output stream owns the callback lifetime. next may be invoked repeatedly or concurrently until that stream settles; Relay then rejects or cancels unfinished and later calls.

Auto Trait Implementations§

§

impl<'a> !Send for PluginContext<'a>

§

impl<'a> !Sync for PluginContext<'a>

§

impl<'a> Freeze for PluginContext<'a>

§

impl<'a> RefUnwindSafe for PluginContext<'a>

§

impl<'a> Unpin for PluginContext<'a>

§

impl<'a> UnsafeUnpin for PluginContext<'a>

§

impl<'a> UnwindSafe for PluginContext<'a>

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, 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.