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_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: Fn(LlmRequest) -> 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: Fn(Json) -> 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 v1 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_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: NemoRelayNativeLlmRequestCb, 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: NemoRelayNativeJsonCb, 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.

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.