Skip to main content

Crate whisker_driver_sys

Crate whisker_driver_sys 

Source
Expand description

Raw extern "C" declarations matching bridge/include/whisker_bridge.h.

Everything here is unsafe to call. Safe wrappers (and the host shim whisker_app_main / whisker_tick exports) live in whisker-driver. Users never depend on this crate directly.

Structs§

WhiskerBytesRef
struct { const uint8_t* ptr; size_t len; } member.
WhiskerElement
WhiskerEngine
WhiskerKeyValueRaw
struct WhiskerKeyValueRec — string-keyed entry of the map variant.
WhiskerStringRef
struct { const char* ptr; size_t len; } member of the C union (also used as the key field of WhiskerKeyValueRaw).
WhiskerValueArray
struct WhiskerValueArrayRec — pointer to count WhiskerValueRaw items.
WhiskerValueMap
struct WhiskerValueMapRec — pointer to count WhiskerKeyValueRaw entries.
WhiskerValueRaw
Raw FFI form of WhiskerValue — byte-for-byte compatible with the C struct WhiskerValueRec. Total size = 24 bytes (1 discriminant + 7 padding + 16 union = 24).

Enums§

WhiskerElementTag
WhiskerValueType
Discriminant for WhiskerValueRaw::type_. Must stay in lock step with enum WhiskerValueType in whisker_bridge.h.

Constants§

LYNX_LIST_INVALID_INDEX
Mirror of LYNX_LIST_INVALID_INDEX (the C macro in lynx_capi.h) — returned by LynxListComponentAtIndexFn to signal “no element could be produced for this index”. Matches Lynx’s lynx::tasm::list::kInvalidIndex; 0 is a real impl_id and would be silently consumed.

Functions§

whisker_bridge_append_child
whisker_bridge_create_element
whisker_bridge_create_element_by_name
whisker_bridge_debug_log_i32
whisker_bridge_dispatch
whisker_bridge_element_animate
Element-level animation dispatch — element.animate(...) shape.
whisker_bridge_element_sign
The Lynx element sign for element — same id the reporter reports as the event target, used as the key for the driver’s tree + listener maps. Returns 0 for a null element.
whisker_bridge_engine_attach
whisker_bridge_engine_release
whisker_bridge_flush
whisker_bridge_invoke_element_method
Invoke a Lynx UI method on a mounted element. Synchronous — dispatches through Lynx’s LynxUIMethodProcessor (iOS) / LynxUIMethodsExecutor (Android), which in turn calls the @WhiskerUIMethod-emitted forwarder on the element’s WhiskerUI<View> subclass.
whisker_bridge_invoke_element_method_async
Async, result-returning element-method dispatch (boundingClientRect / takeScreenshot). Returns immediately; callback(user_data, &result) fires once the method completes (typically on the UI thread). On precondition failure / an unsupported platform the bridge invokes callback synchronously with a WHISKER_VALUE_ERROR and returns false.
whisker_bridge_invoke_element_method_async_with_params
The unified element-method dispatch: params (a single WHISKER_VALUE_MAP) is passed through as the method’s params object directly, and the result arrives via callback. The one entry ElementRef::invoke / invoke_typed build on — both fire-and-forget actions (callback ignored) and result methods.
whisker_bridge_invoke_element_method_with_params
Fire-and-forget dispatch of a built-in Lynx UI method whose arguments are named fields of the params object (scrollTo, scrollBy, autoScroll, scrollIntoView, requestUIInfo, …) rather than the {"args": […]} wrapper whisker_bridge_invoke_element_method builds. params is a single WHISKER_VALUE_MAP; it (and any nested maps / arrays) is passed through as the params object directly. Returns WHISKER_VALUE_NULL once dispatch is scheduled (caller still passes it to whisker_bridge_value_release).
whisker_bridge_invoke_module
Invoke a registered Whisker platform module’s method, synchronously. See whisker_bridge.h for ownership rules around the returned WhiskerValueRaw.
whisker_bridge_invoke_module_async
Async variant. Caller-supplied callback fires once the method completes. user_data is opaque — caller owns lifetime / dropping.
whisker_bridge_list_set_item_count
whisker_bridge_list_set_native_item_provider
whisker_bridge_log_info
Write msg to adb logcat (Android only — no-op on iOS; debug print path that survives Android’s stderr-is-dropped policy). tag == NULL defaults to “WhiskerRust”.
whisker_bridge_module_add_event_listener
Register callback against (module_name, event_name). Returns a positive listener id on success, or <= 0 on a precondition failure. The Rust wrapper hands the caller a ModuleSubscription that calls whisker_bridge_module_remove_event_listener on drop.
whisker_bridge_module_register_observer_hooks
Register OnStart / OnStopObserving hooks for module_name. The bridge calls started(event) on the 0→1 listener-count transition and stopped(event) on 1→0, so the native module can spin up / tear down an expensive source (e.g. an OnBackInvokedCallback registration) only while needed.
whisker_bridge_module_remove_event_listener
Remove a previously-registered listener. No-op if listener_id is unknown. The bridge does not free the caller’s user_data.
whisker_bridge_module_send_event
Dispatch payload to every listener registered against (module_name, event_name). Called from the native module side (sendEvent on Swift / Kotlin). payload may be NULL for an unparameterised ping.
whisker_bridge_register_event_dispatcher
Register the Rust event dispatcher (the reporter hook forwards to it). Called once by the driver at bootstrap. See WhiskerEventDispatcher.
whisker_bridge_register_module_dispatch
Register a dispatch function for module_name. Called by the platform-side generated code at app launch (Swift Macro emits a @_cdecl fn + registration call; KSP emits a JNI wrapper that does the equivalent). Phase 7-Φ.F.
whisker_bridge_release_element
whisker_bridge_remove_child
whisker_bridge_set_attribute
whisker_bridge_set_attribute_bool
whisker_bridge_set_attribute_double
whisker_bridge_set_attribute_int
whisker_bridge_set_event_listener
whisker_bridge_set_event_listener_with_value
whisker_bridge_set_inline_styles
whisker_bridge_set_native_event_handler
Register a bubble-phase event handler for event_name on element, populating its Lynx event set so the UI component emits the event. The driver calls this for non-gesture (component) events; touch/gesture events don’t need it.
whisker_bridge_set_root
whisker_bridge_value_release
Free any heap allocations the bridge attached to value — caller of whisker_bridge_invoke_module MUST eventually call this on the returned value (no-op for scalars).

Type Aliases§

LynxListComponentAtIndexFn
Called by Lynx’s list machinery when it needs the element for index. Returns the FiberElement’s impl_id (sign) or LYNX_LIST_INVALID_INDEX on failure. reuse_notification is 1 if the embedder may reuse an existing element for this index.
LynxListEnqueueComponentFn
Called when the element at sign leaves the viewport. The provider may pool or release it.
LynxUserDataFreeFn
Free-callback for the user_data cookie. Invoked by the bridge when the list element is destroyed (or the provider is replaced) so a Rust Box<dyn FnMut> packed into user_data can be dropped.
WhiskerEventCallback
WhiskerEventDispatcher
The Rust event dispatcher the bridge calls when its reporter hook fires. Receives the hit-tested target’s element sign, the event name (NUL-terminated), and the event body (WhiskerValueRaw tree, never NULL). Returns whether the event was consumed (so the reporter can tell Lynx to skip its native chain). See whisker_bridge_register_event_dispatcher.
WhiskerEventValueCallback
Value-payload event callback. payload is a WhiskerValueRaw tree (never NULL — the bridge normalises a missing body to a WHISKER_VALUE_NULL value), owned by the bridge and only valid for the duration of the call (copy out via from_raw). See whisker_bridge_set_event_listener_with_value.
WhiskerModuleCallback
Callback type for whisker_bridge_invoke_module_async. The result pointer is borrowed for the duration of the call only — the bridge frees the underlying allocations once the callback returns, so closures that need to retain the value must copy into Rust-owned storage via the whisker-runtime wrapper.
WhiskerModuleDispatchFn
Per-module dispatch function — the platform-side Swift Macro or KSP processor emits one of these per @WhiskerModule-annotated class. The bridge stores (module_name → dispatch_fn) in a lookup table; whisker_bridge_invoke_module then routes calls through the registered function directly (Phase 7-Φ.F).
WhiskerModuleEventCallback
Callback type for module event subscriptions. Fired by the bridge when a registered (module, event) pair receives a whisker_bridge_module_send_event call. payload is borrowed — the bridge frees its allocations once the callback returns.
WhiskerModuleObserverHook
Callback type for OnStartObserving / OnStopObserving hooks. The bridge fires these on the 0↔1 listener-count transition for a (module, event) pair. Both module_name and event_name are borrowed (NUL-terminated UTF-8) — copy if you need to retain them past the call. module_name lets a shared platform-side trampoline index its own per-module table.
WhiskerTasmCallback

Unions§

WhiskerValueUnion
#[repr(C)] union mirroring the inner anonymous union of WhiskerValueRec. Field access is unsafe — discriminate on the outer struct’s type_ before reading.