pub struct Runtime { /* private fields */ }Expand description
The top-level NextVision runtime.
Manages cross-feed concerns: feed registry, global limits, and shutdown.
Create via Runtime::builder().
Use handle() to obtain a cloneable RuntimeHandle
for concurrent control from multiple threads. The Runtime itself can
also be used directly for convenience.
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn builder() -> RuntimeBuilder
pub fn builder() -> RuntimeBuilder
Create a new RuntimeBuilder.
Sourcepub fn handle(&self) -> RuntimeHandle
pub fn handle(&self) -> RuntimeHandle
Obtain a cloneable RuntimeHandle.
The handle provides the same control surface as Runtime but can
be cloned and shared across threads.
Sourcepub fn feed_count(&self) -> Result<usize, NvError>
pub fn feed_count(&self) -> Result<usize, NvError>
Number of currently active feeds.
§Errors
Returns RuntimeError::RegistryPoisoned if the internal lock is poisoned.
Sourcepub fn uptime(&self) -> Duration
pub fn uptime(&self) -> Duration
Elapsed time since the runtime was created.
Monotonically increasing. Useful for uptime dashboards and health checks.
Sourcepub fn diagnostics(&self) -> Result<RuntimeDiagnostics, NvError>
pub fn diagnostics(&self) -> Result<RuntimeDiagnostics, NvError>
Get a consolidated diagnostics snapshot of the runtime and all feeds.
Returns per-feed lifecycle state, metrics, queue depths, decode status, and view-system health, plus batch coordinator metrics and output channel lag status.
Designed for periodic polling (1–5 s) by dashboards and health
probes. Complement with health_subscribe()
for event-driven state transitions.
§Errors
Returns RuntimeError::RegistryPoisoned if an internal lock is poisoned.
Sourcepub fn health_subscribe(&self) -> Receiver<HealthEvent>
pub fn health_subscribe(&self) -> Receiver<HealthEvent>
Subscribe to aggregate health events from all feeds.
Sourcepub fn output_subscribe(&self) -> Receiver<SharedOutput>
pub fn output_subscribe(&self) -> Receiver<SharedOutput>
Subscribe to aggregate output from all feeds.
Each subscriber receives an Arc<OutputEnvelope> for every output
produced by any feed. The channel is bounded by the configured
output_capacity (default 256). Slow subscribers will receive
RecvError::Lagged when they fall behind.
Channel saturation is monitored by an internal sentinel receiver.
When the sentinel detects ring-buffer wrap, the runtime emits a
global HealthEvent::OutputLagged event carrying the
sentinel-observed per-event delta. This is a saturation signal,
not a per-subscriber loss report. Live saturation state is also
available via Runtime::diagnostics() in
RuntimeDiagnostics::output_lag.
Sourcepub fn add_feed(&self, config: FeedConfig) -> Result<FeedHandle, NvError>
pub fn add_feed(&self, config: FeedConfig) -> Result<FeedHandle, NvError>
Add a new feed to the runtime.
§Errors
RuntimeError::FeedLimitExceededif the max feed count is reached.RuntimeError::ShutdownInProgressif shutdown has been initiated.RuntimeError::ThreadSpawnFailedif the OS thread cannot be created.
Sourcepub fn create_batch(
&self,
processor: Box<dyn BatchProcessor>,
config: BatchConfig,
) -> Result<BatchHandle, NvError>
pub fn create_batch( &self, processor: Box<dyn BatchProcessor>, config: BatchConfig, ) -> Result<BatchHandle, NvError>
Create a shared batch coordinator for cross-feed inference.
Returns a clonable BatchHandle that can be shared across
multiple feeds via FeedPipeline::builder().batch(handle).
The coordinator takes ownership of the processor (via Box).
A single coordinator thread is the sole caller of all processor
methods — no Sync bound is required. The coordinator is shut
down automatically when the runtime shuts down.
§Errors
RuntimeError::ShutdownInProgressif shutdown has been initiated.ConfigError::DuplicateBatchProcessorIdif a coordinator with the same processor ID already exists.ConfigError::InvalidPolicyifconfighas invalid values.RuntimeError::ThreadSpawnFailedif the coordinator thread fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Runtime
impl !RefUnwindSafe for Runtime
impl Send for Runtime
impl Sync for Runtime
impl Unpin for Runtime
impl UnsafeUnpin for Runtime
impl !UnwindSafe for Runtime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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