Skip to main content

NemoRelayContextState

Struct NemoRelayContextState 

Source
pub struct NemoRelayContextState { /* private fields */ }
Expand description

Process-global runtime state backing middleware and event emission.

The public API layer stores one shared instance of this type for the process. It contains global middleware registries, lifecycle subscribers, and arbitrary extension slots used by bindings or integrations.

Implementations§

Source§

impl NemoRelayContextState

Source

pub fn new() -> Self

Create an empty runtime state with no registered middleware.

§Returns

A NemoRelayContextState with empty registries, no subscribers, and no extensions.

Source

pub fn set_extension<T: Any + Send + Sync>( &mut self, key: impl Into<String>, value: T, )

Store an arbitrary runtime extension under key.

Extensions let bindings or integrations attach shared state to the process-global runtime without adding new first-class fields.

§Parameters
  • key: Stable identifier for the extension slot.
  • value: Typed extension value to store.
Source

pub fn get_extension<T: Any + Send + Sync>(&self, key: &str) -> Option<&T>

Borrow a typed runtime extension by key.

§Parameters
  • key: Extension slot name.
§Returns

Some(&T) when an extension exists under key with the requested type and None otherwise.

Source

pub fn get_extension_mut<T: Any + Send + Sync>( &mut self, key: &str, ) -> Option<&mut T>

Mutably borrow a typed runtime extension by key.

§Parameters
  • key: Extension slot name.
§Returns

Some(&mut T) when an extension exists under key with the requested type and None otherwise.

Source

pub fn remove_extension(&mut self, key: &str) -> bool

Remove a runtime extension by key.

§Parameters
  • key: Extension slot name.
§Returns

true when an extension was removed and false when no extension was stored under key.

Source

pub fn create_event(&self, params: MarkEvent) -> Event

Build a standalone mark event.

§Parameters
§Returns

A mark Event containing the provided MarkEvent.

Source

pub fn create_scope_handle( &self, params: CreateScopeHandleParams<'_>, ) -> ScopeHandle

Create a new scope handle.

§Parameters
  • name: Human-readable scope name.
  • parent_uuid: Optional parent scope UUID.
  • scope_type: Semantic category of the scope.
  • attributes: Scope attribute bitflags.
  • data: Optional application payload stored on the handle.
  • metadata: Optional metadata stored on the handle.
  • timestamp: Optional handle start time. When omitted, the current UTC time is used.
§Returns

A new ScopeHandle with a fresh UUID.

Source

pub fn build_scope_start_event( &self, handle: &ScopeHandle, data: Option<Json>, ) -> Event

Build a scope-start event from a handle.

§Parameters
  • handle: Scope handle to serialize into an event.
  • data: Optional semantic input payload exported on the start event.
§Returns

A scope-start Event derived from the provided handle.

Source

pub fn end_scope_handle( &self, handle: &ScopeHandle, data: Option<Json>, ) -> Event

Build a scope-end event from a handle.

§Parameters
  • handle: Scope handle to serialize into an event.
  • data: Optional data payload returned from the scope.
§Returns

A scope-end Event derived from the provided handle.

Source

pub fn build_scope_end_event(&self, params: EndScopeHandleParams<'_>) -> Event

Build a scope-end event from builder parameters.

§Parameters
  • params: Scope end-event builder parameters.
§Returns

A scope-end Event derived from the provided parameters.

Source

pub fn create_tool_handle( &self, params: CreateToolHandleParams<'_>, ) -> ToolHandle

Create a new tool handle.

§Parameters
  • name: Tool name recorded on emitted events.
  • parent_uuid: Optional parent scope UUID.
  • attributes: Tool attribute bitflags.
  • data: Optional application payload stored on the handle.
  • metadata: Optional metadata stored on the handle.
  • tool_call_id: Optional provider-specific correlation identifier.
  • timestamp: Optional handle start time. When omitted, the current UTC time is used.
§Returns

A new ToolHandle with a fresh UUID.

Source

pub fn build_tool_start_event( &self, handle: &ToolHandle, data: Option<Json>, ) -> Event

Build a tool-start event from a handle.

§Parameters
  • handle: Tool handle to serialize into an event.
  • data: Optional tool input payload.
§Returns

A tool-start Event derived from the provided handle.

Source

pub fn end_tool_handle( &self, handle: &ToolHandle, data: Option<Json>, metadata: Option<Json>, ) -> Event

Build a tool-end event from a handle and optional overrides.

§Parameters
  • handle: Tool handle to serialize into an event.
  • data: Optional end-event data payload.
  • metadata: Optional metadata payload merged over handle.metadata.
§Returns

A tool-end Event derived from the provided handle.

Source

pub fn build_tool_end_event(&self, params: EndToolHandleParams<'_>) -> Event

Build a tool-end event from builder parameters.

The metadata payload is merged over the metadata already stored on the handle.

§Parameters
  • params: Tool end-event builder parameters.
§Returns

A tool-end Event derived from the provided parameters.

Source

pub fn create_llm_handle(&self, params: CreateLlmHandleParams<'_>) -> LlmHandle

Create a new LLM handle.

§Parameters
  • name: Logical provider or model family name.
  • parent_uuid: Optional parent scope UUID.
  • attributes: LLM attribute bitflags.
  • data: Optional application payload stored on the handle.
  • metadata: Optional metadata stored on the handle.
  • model_name: Optional normalized model name stored on the handle.
  • timestamp: Optional handle start time. When omitted, the current UTC time is used.
§Returns

A new LlmHandle with a fresh UUID.

Source

pub fn build_llm_start_event( &self, handle: &LlmHandle, data: Option<Json>, annotated_request: Option<Arc<AnnotatedLlmRequest>>, ) -> Event

Build an LLM-start event from a handle.

§Parameters
  • handle: LLM handle to serialize into an event.
  • data: Sanitized LLM request payload.
  • annotated_request: Optional normalized request annotation.
§Returns

An LLM-start Event derived from the provided handle.

Source

pub fn end_llm_handle( &self, handle: &LlmHandle, data: Option<Json>, metadata: Option<Json>, annotated_response: Option<Arc<AnnotatedLlmResponse>>, ) -> Event

Build an LLM-end event from a handle and optional overrides.

§Parameters
  • handle: LLM handle to serialize into an event.
  • data: Sanitized LLM response payload.
  • metadata: Optional metadata payload merged over handle.metadata.
  • annotated_response: Optional normalized response annotation.
§Returns

An LLM-end Event derived from the provided handle.

Source

pub fn build_llm_end_event(&self, params: EndLlmHandleParams<'_>) -> Event

Build an LLM-end event from builder parameters.

The metadata payload is merged over the metadata already stored on the handle.

§Parameters
  • params: LLM end-event builder parameters.
§Returns

An LLM-end Event derived from the provided parameters.

Trait Implementations§

Source§

impl Default for NemoRelayContextState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more