use std::sync::Arc;
use nativeview_abi::{
FrameId, HostServiceId, NvDirectHostEnv, NvHostCallbacks, NvPropsRef, NvSizeConstraints,
NvSurfaceMeasure, ValidatedEvents,
};
use nativeview_store::{ChangeSet, NodeStore};
pub use crate::ext::frame::FrameTickHook;
use crate::tracker::PointerCaptureRequest;
use crate::HotPatchMsg;
use crate::wake::WakeBridge;
pub enum AppFrame<'a> {
Clean,
Direct { changes: &'a ChangeSet },
Wire(&'a [u8]),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct CapabilityUnsupported;
pub trait RuntimeApp {
fn render_frame(&mut self, frame_id: FrameId) -> AppFrame<'_>;
fn dispatch_events(&mut self, events: ValidatedEvents<'_>) -> bool;
fn take_close_request(&mut self) -> bool {
false
}
fn take_unconsumed_key(&mut self) -> bool {
false
}
fn drain_pointer_capture_requests(&mut self, _sink: &mut dyn FnMut(PointerCaptureRequest)) {}
fn direct_store(&self) -> Option<&NodeStore> {
None
}
fn direct_store_mut(&mut self) -> Option<&mut NodeStore> {
None
}
fn poll_async_work(&mut self) -> bool {
false
}
fn install_wake_bridge(&mut self, _wake: Arc<WakeBridge>) -> bool {
false
}
fn apply_hot_patch(&mut self, _patch: &HotPatchMsg) -> Result<bool, CapabilityUnsupported> {
Err(CapabilityUnsupported)
}
fn set_props(&mut self, _props: NvPropsRef<'_>) -> Result<bool, CapabilityUnsupported> {
Err(CapabilityUnsupported)
}
fn drain_emitted_events(&mut self) -> Result<ValidatedEvents<'_>, CapabilityUnsupported> {
Err(CapabilityUnsupported)
}
fn supports_state(&self) -> bool {
false
}
fn snapshot_state(&mut self) -> Result<&[u8], CapabilityUnsupported> {
Err(CapabilityUnsupported)
}
fn restore_state(&mut self, _state: &[u8]) -> Result<(), CapabilityUnsupported> {
Err(CapabilityUnsupported)
}
fn measure_surface(
&mut self,
_constraints: NvSizeConstraints,
_flags: u32,
) -> Option<NvSurfaceMeasure> {
None
}
fn bind_host(&mut self, _callbacks: Option<NvHostCallbacks>) {}
fn dispatch_host_events(&mut self, _batch: &[u8]) -> bool {
false
}
fn bind_direct_host(&mut self, _env: Option<NvDirectHostEnv>) {}
fn dispatch_direct_completion(
&mut self,
_local_req_id: u64,
_status: i32,
_payload: &[u8],
) -> bool {
false
}
fn dispatch_direct_event(
&mut self,
_service_id: HostServiceId,
_event_id: u32,
_flags: u32,
_payload: &[u8],
) -> bool {
false
}
}