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 PluginContext<'_>

Source

pub fn register_event_metadata_injector<F, Fut>( &mut self, name: &str, priority: i32, callback: F, ) -> Result<()>
where F: Fn(Arc<Event>) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<BTreeMap<String, Json>>> + Send + 'static,

Registers an asynchronous Event metadata injector.

Source

pub fn register_mark_sanitize_guardrail<F, Fut>( &mut self, name: &str, priority: i32, callback: F, ) -> Result<()>
where F: Fn(Arc<Event>, EventSanitizeFields) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<EventSanitizeFields>> + Send + 'static,

Registers an asynchronous mark-event sanitizer.

Source

pub fn register_scope_sanitize_start_guardrail<F, Fut>( &mut self, name: &str, priority: i32, callback: F, ) -> Result<()>
where F: Fn(Arc<Event>, EventSanitizeFields) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<EventSanitizeFields>> + Send + 'static,

Registers an asynchronous scope-start sanitizer.

Source

pub fn register_scope_sanitize_end_guardrail<F, Fut>( &mut self, name: &str, priority: i32, callback: F, ) -> Result<()>
where F: Fn(Arc<Event>, EventSanitizeFields) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<EventSanitizeFields>> + Send + 'static,

Registers an asynchronous scope-end sanitizer.

Source

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

Registers an asynchronous tool request sanitizer.

Source

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

Registers an asynchronous tool response sanitizer.

Source

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

Registers an asynchronous tool conditional-execution guardrail.

Source

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

Registers an asynchronous tool request intercept.

Source

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

Registers an asynchronous tool execution intercept.

Source

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

Registers an asynchronous LLM request sanitizer.

Source

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

Registers an asynchronous LLM response sanitizer.

Source

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

Registers an asynchronous LLM conditional-execution guardrail.

Source

pub fn register_llm_request_intercept<F, Fut>( &mut self, name: &str, priority: i32, break_chain: bool, callback: F, ) -> Result<()>
where F: Fn(String, LlmRequest, Option<AnnotatedLlmRequest>) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<LlmRequestInterceptOutcome>> + Send + 'static,

Registers an asynchronous LLM request intercept.

Source

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

Registers an asynchronous LLM execution intercept.

Source

pub fn register_llm_stream_execution_intercept<F, Fut>( &mut self, name: &str, priority: i32, callback: F, ) -> Result<()>
where F: Fn(String, LlmRequest, LlmStreamNext) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<LlmJsonAsyncStream>> + Send + 'static,

Registers an asynchronous LLM stream execution intercept.

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_conditional_middleware_guardrail<F>( &mut self, name: &str, kinds: &BTreeSet<RuntimeRegistrationKind>, registration_name: &str, callback: F, ) -> Result<()>
where F: Fn(&BTreeSet<RuntimeRegistrationKind>, &str) -> Option<String> + Send + Sync + 'static,

Declares a callback conditional middleware guardrail for activation.

Return Some(reason) to disable the matching target or None to leave it enabled.

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 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. This call consumes the user_data ownership even when it rejects the host ABI. 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; this call consumes user_data even when it rejects the host ABI. Callback-owned next and stream handles must each be released exactly once. Stream pushes and rejection are nonblocking: Retry only NemoRelayStatus::Backpressured operations. 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 = !

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.