#[repr(C)]pub struct NodeAppContext {
pub host_data: *const c_void,
pub host_log: unsafe extern "C" fn(*const c_void, u32, *const i8),
pub host_get_config: unsafe extern "C" fn(*const c_void, *const i8) -> *const i8,
pub host_set_storage: unsafe extern "C" fn(*const c_void, *const i8, *const i8),
pub host_get_storage: unsafe extern "C" fn(*const c_void, *const i8) -> *const i8,
pub host_invoke_capability: unsafe extern "C" fn(*const c_void, *const u8, usize) -> FfiResult,
pub host_publish_event: unsafe extern "C" fn(*const c_void, *const u8, usize, *const u8, usize) -> i32,
}Expand description
Host context provided to native apps.
Contains function pointers for callbacks into the host. The context pointer is valid for the lifetime of the app.
Fields§
§host_data: *const c_voidOpaque pointer to host-side state (passed as first arg to callbacks)
host_log: unsafe extern "C" fn(*const c_void, u32, *const i8)Log a message at the specified level.
level: 0=trace, 1=debug, 2=info, 3=warn, 4=error
message: null-terminated UTF-8 string
host_get_config: unsafe extern "C" fn(*const c_void, *const i8) -> *const i8Get a configuration value by key. Returns null if key not found. Caller must NOT free the returned pointer.
host_set_storage: unsafe extern "C" fn(*const c_void, *const i8, *const i8)Set a storage value (scoped to this app). Both key and value are null-terminated UTF-8 strings.
host_get_storage: unsafe extern "C" fn(*const c_void, *const i8) -> *const i8Get a storage value by key (scoped to this app). Returns null if key not found. Caller must NOT free the returned pointer.
host_invoke_capability: unsafe extern "C" fn(*const c_void, *const u8, usize) -> FfiResultInvoke a capability on the host via the capability router.
request_json is a pointer to UTF-8 JSON bytes (CapabilityRequest) of length request_len.
Returns FfiResult with CapabilityResponse JSON in data/data_len.
The caller must free the returned data using the host’s free function.
host_publish_event: unsafe extern "C" fn(*const c_void, *const u8, usize, *const u8, usize) -> i32Publish a domain event to the host event bus.
event_name is a pointer to UTF-8 bytes of length event_name_len (max 256 bytes).
event_data is a pointer to UTF-8 JSON bytes of length event_data_len (max 64KB).
Returns 0 on success, negative error code on failure.
Fire-and-forget semantics: the event is queued asynchronously.