Skip to main content

NodeAppContext

Struct NodeAppContext 

Source
#[repr(C)]
pub struct NodeAppContext { pub host_data: *const c_void, pub host_log: unsafe extern "C" fn(host_data: *const c_void, level: u32, message: *const c_char), pub host_get_config: unsafe extern "C" fn(host_data: *const c_void, key: *const c_char) -> *const c_char, pub host_set_storage: unsafe extern "C" fn(host_data: *const c_void, key: *const c_char, value: *const c_char), pub host_get_storage: unsafe extern "C" fn(host_data: *const c_void, key: *const c_char) -> *const c_char, pub host_invoke_capability: unsafe extern "C" fn(host_data: *const c_void, request_json: *const u8, request_len: usize) -> FfiResult, pub host_publish_event: unsafe extern "C" fn(host_data: *const c_void, event_name: *const u8, event_name_len: usize, event_data: *const u8, event_data_len: 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_void

Opaque pointer to host-side state (passed as first arg to callbacks)

§host_log: unsafe extern "C" fn(host_data: *const c_void, level: u32, message: *const c_char)

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(host_data: *const c_void, key: *const c_char) -> *const c_char

Get 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(host_data: *const c_void, key: *const c_char, value: *const c_char)

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(host_data: *const c_void, key: *const c_char) -> *const c_char

Get 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(host_data: *const c_void, request_json: *const u8, request_len: usize) -> FfiResult

Invoke 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(host_data: *const c_void, event_name: *const u8, event_name_len: usize, event_data: *const u8, event_data_len: usize) -> i32

Publish 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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.