pub trait RuntimeApp {
Show 21 methods
// Required methods
fn render_frame(&mut self, frame_id: FrameId) -> AppFrame<'_>;
fn dispatch_events(&mut self, events: ValidatedEvents<'_>) -> bool;
// Provided methods
fn take_close_request(&mut self) -> bool { ... }
fn take_unconsumed_key(&mut self) -> bool { ... }
fn drain_pointer_capture_requests(
&mut self,
_sink: &mut dyn FnMut(PointerCaptureRequest),
) { ... }
fn direct_store(&self) -> Option<&NodeStore> { ... }
fn direct_store_mut(&mut self) -> Option<&mut NodeStore> { ... }
fn poll_async_work(&mut self) -> bool { ... }
fn install_wake_bridge(&mut self, _wake: Arc<WakeBridge>) -> bool { ... }
fn apply_hot_patch(
&mut self,
_patch: &HotPatchMsg,
) -> Result<bool, CapabilityUnsupported> { ... }
fn set_props(
&mut self,
_props: NvPropsRef<'_>,
) -> Result<bool, CapabilityUnsupported> { ... }
fn drain_emitted_events(
&mut self,
) -> Result<ValidatedEvents<'_>, CapabilityUnsupported> { ... }
fn supports_state(&self) -> bool { ... }
fn snapshot_state(&mut self) -> Result<&[u8], CapabilityUnsupported> { ... }
fn restore_state(
&mut self,
_state: &[u8],
) -> Result<(), CapabilityUnsupported> { ... }
fn measure_surface(
&mut self,
_constraints: NvSizeConstraints,
_flags: u32,
) -> Option<NvSurfaceMeasure> { ... }
fn bind_host(&mut self, _callbacks: Option<NvHostCallbacks>) { ... }
fn dispatch_host_events(&mut self, _batch: &[u8]) -> bool { ... }
fn bind_direct_host(&mut self, _env: Option<NvDirectHostEnv>) { ... }
fn dispatch_direct_completion(
&mut self,
_local_req_id: u64,
_status: i32,
_payload: &[u8],
) -> bool { ... }
fn dispatch_direct_event(
&mut self,
_service_id: HostServiceId,
_event_id: u32,
_flags: u32,
_payload: &[u8],
) -> bool { ... }
}Expand description
Framework-agnostic application contract hosted by nv_runtime::SurfaceRuntime.
Implementations may either own a NodeStore directly (zero wire encode/decode via
AppFrame::Direct) or emit binary NV02 frames (AppFrame::Wire).
Required Methods§
Sourcefn render_frame(&mut self, frame_id: FrameId) -> AppFrame<'_>
fn render_frame(&mut self, frame_id: FrameId) -> AppFrame<'_>
Produces the next frame’s changes (Direct, Wire, or Clean).
Sourcefn dispatch_events(&mut self, events: ValidatedEvents<'_>) -> bool
fn dispatch_events(&mut self, events: ValidatedEvents<'_>) -> bool
Dispatches a direct typed event batch into the application. Returns true when the app
dirtied state and needs a re-render.
Provided Methods§
Sourcefn take_close_request(&mut self) -> bool
fn take_close_request(&mut self) -> bool
Takes the close request of the last Self::dispatch_events: an Escape / GoBack key
down no listener consumed. nv_runtime::SurfaceRuntime routes it to
LaidOutScene::close_request_target ([INV:close-request-single-path]).
Sourcefn take_unconsumed_key(&mut self) -> bool
fn take_unconsumed_key(&mut self) -> bool
Takes whether the last KeyDown of Self::dispatch_events went unconsumed by app
listeners (eligible for post-dispatch runtime DefaultActions).
Sourcefn drain_pointer_capture_requests(
&mut self,
_sink: &mut dyn FnMut(PointerCaptureRequest),
)
fn drain_pointer_capture_requests( &mut self, _sink: &mut dyn FnMut(PointerCaptureRequest), )
Drains the W3C pointer capture requests (setPointerCapture / releasePointerCapture)
listeners made during the last Self::dispatch_events into sink; the runtime applies
them as pending captures before each pointer’s next sample.
Sourcefn direct_store(&self) -> Option<&NodeStore>
fn direct_store(&self) -> Option<&NodeStore>
Borrows the app’s authoritative NodeStore when running in zero-copy direct mode.
Sourcefn direct_store_mut(&mut self) -> Option<&mut NodeStore>
fn direct_store_mut(&mut self) -> Option<&mut NodeStore>
Mutably borrows the app’s authoritative NodeStore (for FrameTickHooks in direct mode).
Sourcefn poll_async_work(&mut self) -> bool
fn poll_async_work(&mut self) -> bool
Polls any pending async work (e.g. reactive tasks or background streams) and arms the
installed WakeBridge waker on newly spawned pending futures. Returns true when new
work became ready and a render should follow.
Sourcefn install_wake_bridge(&mut self, _wake: Arc<WakeBridge>) -> bool
fn install_wake_bridge(&mut self, _wake: Arc<WakeBridge>) -> bool
Installs the runtime’s single coalesced WakeBridge so async tasks wake the host loop
directly without double-layered wake latches.
Returns true if the app had a pending wake prior to installation; callers trigger the
newly installed bridge after releasing any surface write lock.
Sourcefn apply_hot_patch(
&mut self,
_patch: &HotPatchMsg,
) -> Result<bool, CapabilityUnsupported>
fn apply_hot_patch( &mut self, _patch: &HotPatchMsg, ) -> Result<bool, CapabilityUnsupported>
Applies a Tier-1 binary hot-reload patch payload. Ok(true) when the surface dirtied.
Sourcefn set_props(
&mut self,
_props: NvPropsRef<'_>,
) -> Result<bool, CapabilityUnsupported>
fn set_props( &mut self, _props: NvPropsRef<'_>, ) -> Result<bool, CapabilityUnsupported>
Applies embedding-host props (RN / SwiftUI / Compose / Flutter widget props). Ok(true)
when the app needs a re-render.
Sourcefn drain_emitted_events(
&mut self,
) -> Result<ValidatedEvents<'_>, CapabilityUnsupported>
fn drain_emitted_events( &mut self, ) -> Result<ValidatedEvents<'_>, CapabilityUnsupported>
Drains component-emitted outbound events, borrowed until the next call on self.
Sourcefn supports_state(&self) -> bool
fn supports_state(&self) -> bool
true when Self::snapshot_state / Self::restore_state are supported: lets the
runtime check the capability before touching state files, without serializing state.
Sourcefn snapshot_state(&mut self) -> Result<&[u8], CapabilityUnsupported>
fn snapshot_state(&mut self) -> Result<&[u8], CapabilityUnsupported>
Serializes app state (instant boot / Tier-2 hot swap), borrowed until the next call on self.
Sourcefn restore_state(&mut self, _state: &[u8]) -> Result<(), CapabilityUnsupported>
fn restore_state(&mut self, _state: &[u8]) -> Result<(), CapabilityUnsupported>
Restores state produced by Self::snapshot_state; the runtime re-renders afterwards.
Sourcefn measure_surface(
&mut self,
_constraints: NvSizeConstraints,
_flags: u32,
) -> Option<NvSurfaceMeasure>
fn measure_surface( &mut self, _constraints: NvSizeConstraints, _flags: u32, ) -> Option<NvSurfaceMeasure>
Measures the surface under constraints and NV_MEASURE_FLAG_* bits.
Returning Some(measure) delegates sizing to the app (e.g. NV_IFACE_LAYOUT = 2);
returning None falls back to the runtime’s StoreLayoutEngine::measure_root.
Sourcefn bind_host(&mut self, _callbacks: Option<NvHostCallbacks>)
fn bind_host(&mut self, _callbacks: Option<NvHostCallbacks>)
Binds or unbinds the runtime’s NV_IFACE_HOST = 5 callbacks. Called automatically on
attach (Some(callbacks)) and before reload, detach, or drop (None).
Sourcefn dispatch_host_events(&mut self, _batch: &[u8]) -> bool
fn dispatch_host_events(&mut self, _batch: &[u8]) -> bool
Delivers one canonical NVHB v1 host event batch drained from RuntimeHostRouter.
Returns true when the app dirtied state and needs a re-render.
Sourcefn bind_direct_host(&mut self, _env: Option<NvDirectHostEnv>)
fn bind_direct_host(&mut self, _env: Option<NvDirectHostEnv>)
Binds or unbinds the runtime’s NV_IFACE_DIRECT_HOST = 6 environment (NvDirectHostEnv).
Called on attach (Some(env)) and before reload, detach, or drop (None).
Sourcefn dispatch_direct_completion(
&mut self,
_local_req_id: u64,
_status: i32,
_payload: &[u8],
) -> bool
fn dispatch_direct_completion( &mut self, _local_req_id: u64, _status: i32, _payload: &[u8], ) -> bool
Delivers one completed direct-FFI async response on the owner thread (NV_IFACE_DIRECT_HOST = 6).
Returns true when the app dirtied state and needs a re-render.
Sourcefn dispatch_direct_event(
&mut self,
_service_id: HostServiceId,
_event_id: u32,
_flags: u32,
_payload: &[u8],
) -> bool
fn dispatch_direct_event( &mut self, _service_id: HostServiceId, _event_id: u32, _flags: u32, _payload: &[u8], ) -> bool
Delivers one direct-FFI push event on the owner thread (NV_IFACE_DIRECT_HOST = 6).
Returns true when the app dirtied state and needs a re-render.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".