Skip to main content

Crate cranpose_native

Crate cranpose_native 

Source
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§

NativeContent
Application content and commands, created on the component’s owning thread.
NativeEvent
One application event exchanged with the native host.
NativeFrame
A presentation update. Empty pixels preserve the currently presented image and slots.
NativeSession
Owns an embedded composition and its worker thread.
NativeSlot
One mounted native child.

Enums§

NativeError
A native hosting failure.
TouchPhase
Touch input in logical host coordinates.
WebViewEvent
An event from an embedded browser.

Traits§

FrameListener
Wakes a platform view when its composition needs a frame.

Functions§

NativeView
Reserves a native child with an application-defined factory and configuration.
SendToHost
Sends an application event to the native host after this composition commits.
WebView
Embeds a website inside the component’s layout bounds.