Expand description
Shared runtime and native-language bindings for embedding Cranpose in native views.
§Cranpose Native
cranpose-native embeds a Cranpose composition in a native host view. Native
application authors create a NativeSession, exchange named events, and read
frame updates. The session owns a worker for composition state. Framework
integrators can use NativeView to mount platform controls inside Cranpose UI.
§Create a session
The factory creates content on the session’s worker. The helper below wraps a
root UI closure in NativeContent:
use cranpose_native::{NativeContent, NativeSession};
use std::sync::Arc;
fn create_session(root: impl FnMut() + Send + 'static) -> Arc<NativeSession> {
NativeSession::new(move || NativeContent::new(root))
}The host drives frame, forwards input with touch or send_event, and calls
shutdown when the view leaves the host. A platform adapter can attach a
FrameListener and request work from its UI loop. The crate selects the WGPU
renderer and embedded fallback font through its cranpose dependency. Cargo
feature selection lives on cranpose.
See the NativeSession API,
the native demo,
the host integration guide
and the crate source.
Structs§
- Native
Content - Application content and commands, created on the component’s owning thread.
- Native
Event - One application event exchanged with the native host.
- Native
Frame - A presentation update. Empty pixels preserve the currently presented image and slots.
- Native
Session - Owns an embedded composition and its worker thread.
- Native
Slot - One mounted native child.
Enums§
- Native
Error - A native hosting failure.
- Touch
Phase - Touch input in logical host coordinates.
- WebView
Event - An event from an embedded browser.
Traits§
- Frame
Listener - Wakes a platform view when its composition needs a frame.
Functions§
- Native
View - Reserves a native child with an application-defined factory and configuration.
- Send
ToHost - Sends an application event to the native host after this composition commits.
- WebView
- Embeds a website inside the component’s layout bounds.