Skip to navigation

Generated from cargo doc --no-deps -p nemo-relay-builtins -p nemo-relay-diagnostics -p nemo-relay-logging -p nemo-relay-plugin-host -p nemo-relay-codecs -p nemo-relay -p nemo-relay-runtime -p nemo-relay-model-pricing -p nemo-relay-resource-metrics -p nemo-relay-observability -p nemo-relay-adaptive -p nemo-relay-pii-redaction -p nemo-relay-ffi -p nemo-relay-types -p nemo-relay-plugin -p nemo-relay-worker-proto -p nemo-relay-worker.

pub struct PluginRuntime { /* private fields */ }

Cloneable runtime capabilities supplied by the host to a native plugin.

Access scopes, emit telemetry, and inspect runtime state without depending on the runtime implementation. Obtain it from PluginContext::runtime.

Implementations

impl PluginRuntime

impl PluginRuntime

Referenced types: PluginRuntime

diagnostics

pub fn diagnostics(&self) -> Diagnostics

Referenced types: Diagnostics

Access diagnostic submission and authorized reads for this plugin.

current_scope_stack_snapshot

pub fn current_scope_stack_snapshot(&self) -> Result<Option<ScopeStackSnapshot>>

Referenced types: Option, ScopeStackSnapshot

Capture the current scope stack, or return None when no stack is active.

list_runtime_registrations

pub fn list_runtime_registrations(
&self,
kinds: Option<&BTreeSet<RuntimeRegistrationKind>>,
) -> Result<Vec<RuntimeRegistrationIdentity>>

Referenced types: Option, BTreeSet, RuntimeRegistrationKind, Vec, RuntimeRegistrationIdentity

List active runtime registrations, optionally restricted to the supplied kinds.

scope_stack_active

pub fn scope_stack_active(&self) -> bool

Referenced types: bool

Return whether a scope stack is active; return false if the host lookup fails.

current_scope

pub fn current_scope(&self) -> Result<ScopeHandle<'_>>

Referenced types: ScopeHandle

Get the current scope handle or fail if the host reports no current scope.

push_scope

pub fn push_scope(
&self,
name: &str,
scope_type: ScopeType,
data: Option<&Json>,
metadata: Option<&Json>,
input: Option<&Json>,
) -> Result<ScopeHandle<'_>>

Referenced types: str, ScopeType, Option, Json, ScopeHandle

Push a scope using the default parent, attributes, and start time.

push_scope_with_options

pub fn push_scope_with_options(
&self,
name: &str,
scope_type: ScopeType,
data: Option<&Json>,
metadata: Option<&Json>,
input: Option<&Json>,
options: ScopeOptions<'_>,
) -> Result<ScopeHandle<'_>>

Referenced types: str, ScopeType, Option, Json, ScopeOptions, ScopeHandle

Push a scope with an explicit parent, behavior flags, or start time.

pop_scope

pub fn pop_scope(
&self,
handle: &ScopeHandle<'_>,
output: Option<&Json>,
metadata: Option<&Json>,
) -> Result<()>

Referenced types: ScopeHandle, Option, Json, ()

Close a scope with optional output and final metadata.

scope

pub fn scope(
&self,
name: &str,
scope_type: ScopeType,
data: Option<&Json>,
metadata: Option<&Json>,
input: Option<&Json>,
) -> Result<ScopeGuard<'_>>

Referenced types: str, ScopeType, Option, Json, ScopeGuard

Push a scope and return a guard that closes it when dropped.

scope_with_options

pub fn scope_with_options(
&self,
name: &str,
scope_type: ScopeType,
data: Option<&Json>,
metadata: Option<&Json>,
input: Option<&Json>,
options: ScopeOptions<'_>,
) -> Result<ScopeGuard<'_>>

Referenced types: str, ScopeType, Option, Json, ScopeOptions, ScopeGuard

Open a scope guard with an explicit parent, behavior flags, or start time.

scope_at

pub fn scope_at(
&self,
name: &str,
scope_type: ScopeType,
data: Option<&Json>,
metadata: Option<&Json>,
input: Option<&Json>,
started_at: SystemTime,
) -> Result<ScopeGuard<'_>>

Referenced types: str, ScopeType, Option, Json, SystemTime, ScopeGuard

Open a scope guard with an explicit start time.

emit_mark

pub fn emit_mark(
&self,
name: &str,
data: Option<&Json>,
metadata: Option<&Json>,
) -> Result<()>

Referenced types: str, Option, Json, ()

Emit a mark with optional data and metadata in the current scope.

emit_mark_with_options

pub fn emit_mark_with_options(
&self,
name: &str,
data: Option<&Json>,
metadata: Option<&Json>,
data_schema: Option<&DataSchema>,
severity: Option<LogSeverity>,
) -> Result<()>

Referenced types: str, Option, Json, DataSchema, LogSeverity, ()

Emit a mark in the current scope with an optional schema and severity.

emit_mark_with_context

pub fn emit_mark_with_context(
&self,
name: &str,
data: Option<&Json>,
metadata: Option<&Json>,
options: EmitMarkOptions<'_>,
) -> Result<()>

Referenced types: str, Option, Json, EmitMarkOptions, ()

Emit a mark with an explicit parent, timestamp, schema, or severity.

emit_metric

pub fn emit_metric(
&self,
name: &str,
measurements: Vec<MetricMeasurement>,
metadata: Option<&Json>,
) -> Result<()>

Referenced types: str, Vec, MetricMeasurement, Option, Json, ()

Validate metric measurements and emit them using Relay’s reserved metric schema.

runtime_diagnostics

pub fn runtime_diagnostics(&self) -> Result<RuntimeDiagnostics>

Referenced types: RuntimeDiagnostics

Read the runtime diagnostic report exposed by the host.

estimate_cost_for_provider

pub fn estimate_cost_for_provider(
&self,
provider: Option<&str>,
model: &str,
usage: &Usage,
) -> Result<Option<CostEstimate>>

Referenced types: Option, str, Usage, CostEstimate

Estimate cost with the host’s active model pricing catalog.

Returns Ok(None) when the catalog has no pricing for the model. Hosts older than this operation return an error, which callers should treat as an unknown cost.

response_cost_for_provider

pub fn response_cost_for_provider(
&self,
response: &AnnotatedLlmResponse,
provider: Option<&str>,
) -> Result<Option<CostEstimate>>

Referenced types: AnnotatedLlmResponse, Option, str, CostEstimate

Price a normalized response with the host’s full pricing rules.

Returns the response’s reported cost when present; otherwise the host’s estimate for its model and usage, or Ok(None) when unknown. Hosts older than this operation return an error, which callers should treat as an unknown cost.

log

pub fn log(
&self,
level: PluginLogLevel,
target: &str,
message: &str,
fields: Option<&Json>,
) -> Result<()>

Referenced types: PluginLogLevel, str, Option, Json, ()

Send a process log record with optional structured fields through the host runtime capability.

create_scope_stack

pub fn create_scope_stack(&self) -> Result<ScopeStack<'_>>

Referenced types: ScopeStack

Create an isolated host-owned scope stack whose handle releases it when dropped.

capture_scope_stack_thread

pub fn capture_scope_stack_thread(&self) -> Result<ScopeStackBinding<'_>>

Referenced types: ScopeStackBinding

Capture this thread’s scope binding so it can be restored later.

bind_scope_stack_thread

pub fn bind_scope_stack_thread<'a>(
&'a self,
stack: &'a ScopeStack<'a>,
) -> Result<ThreadScopeStackGuard<'a>>

Referenced types: ScopeStack, ThreadScopeStackGuard

Install an isolated stack until the returned guard restores the previous thread binding.

register_conditional_middleware_guardrail

pub fn register_conditional_middleware_guardrail<F>(
&self,
name: &str,
kinds: &BTreeSet<RuntimeRegistrationKind>,
registration_name: &str,
callback: F,
) -> Result<ConditionalMiddlewareGuardrailHandle>where
F: Fn(&BTreeSet<RuntimeRegistrationKind>, &str) -> Option<String> + Send + Sync + 'static,

Referenced types: str, BTreeSet, RuntimeRegistrationKind, ConditionalMiddlewareGuardrailHandle, Fn, Option, String, Send, Sync

Register a revocable synchronous gate scoped to this component’s lifetime.

deregister_conditional_middleware_guardrail

pub fn deregister_conditional_middleware_guardrail(
&self,
handle: &ConditionalMiddlewareGuardrailHandle,
) -> Result<bool>

Referenced types: ConditionalMiddlewareGuardrailHandle, bool

Remove the conditional middleware guardrail identified by its registration token.

impl PluginRuntime

impl PluginRuntime

Referenced types: PluginRuntime

trace

pub fn trace(
&self,
target: &str,
message: &str,
fields: Option<&Json>,
) -> Result<()>

Referenced types: str, Option, Json, ()

Emit a trace plugin log record through the host.

impl PluginRuntime

impl PluginRuntime

Referenced types: PluginRuntime

debug

pub fn debug(
&self,
target: &str,
message: &str,
fields: Option<&Json>,
) -> Result<()>

Referenced types: str, Option, Json, ()

Emit a debug plugin log record through the host.

impl PluginRuntime

impl PluginRuntime

Referenced types: PluginRuntime

info

pub fn info(
&self,
target: &str,
message: &str,
fields: Option<&Json>,
) -> Result<()>

Referenced types: str, Option, Json, ()

Emit a info plugin log record through the host.

impl PluginRuntime

impl PluginRuntime

Referenced types: PluginRuntime

warn

pub fn warn(
&self,
target: &str,
message: &str,
fields: Option<&Json>,
) -> Result<()>

Referenced types: str, Option, Json, ()

Emit a warn plugin log record through the host.

impl PluginRuntime

impl PluginRuntime

Referenced types: PluginRuntime

error

pub fn error(
&self,
target: &str,
message: &str,
fields: Option<&Json>,
) -> Result<()>

Referenced types: str, Option, Json, ()

Emit a error plugin log record through the host.

Trait Implementations

impl Clone for PluginRuntime

impl Clone for PluginRuntime

Referenced types: Clone, PluginRuntime

clone

fn clone(&self) -> PluginRuntime

Referenced types: clone, PluginRuntime

clone_from

fn clone_from(&mut self, source: &Self)

Referenced types: clone_from