node-app-sdk-rust
Status:
1.0.0-experimental— API surface is frozen pending validation by at least two first-party packages. Breaking changes between1.0.0-experimental.*releases are possible. Pin to an exact version in production.
Rust SDK for building Node-App native plugins as shared libraries (.so / .dylib / .dll). Node-Apps run inside the Node Lightning-powered marketplace daemon and communicate with the host through a stable C ABI.
What it gives you
- A
NodeApptrait — implement it on your plugin type to get HTTP, event, and capability handling. - The
declare_node_app!macro — generates all FFI boilerplate (vtable, panic guards, JSON serialization) from your trait impl. - Helpers for talking to the host:
log_info!,invoke_capability,publish_event,get_config,get_storage,set_storage. - Distributed-trace propagation across capability invocations (thread-local span context).
- Hard limits matching the host:
MAX_CAPABILITY_RESPONSE_SIZE(16 MiB),MAX_EVENT_NAME_LEN(256 B),MAX_EVENT_DATA_LEN(64 KiB).
Quick start
Add to your Cargo.toml:
[]
= "my-node-app"
= "0.1.0"
= "2021"
[]
= ["cdylib"] # required: host loads via libloading
[]
= "1.0.0-experimental"
= "1.0"
src/lib.rs:
use *;
;
declare_node_app!;
Build:
# Output: target/release/libmy_node_app.so (Linux), .dylib (macOS), .dll (Windows)
Drop the resulting shared library into the host's app directory alongside a manifest.json. The host discovers it on startup or via app.discover.
Calling host capabilities
use ;
let response = invoke_capability?;
Trace context (trace_id / span_id / trace_depth) is propagated automatically when invoking from inside handle_capability — you don't need to thread it manually.
Publishing events
use publish_event;
publish_event?;
Event names must be namespaced with your app name (my-app.*); the host rejects un-namespaced events.
ABI stability
This SDK targets Node Host API v1. The C ABI is defined by node-app-api (re-exported here) and the canonical C header lives at core/host-abi-v1/include/node-host-api-v1.h in the host repo. Apps declare their API version in NodeAppMetadata.api_version; the host refuses to load apps with mismatched versions.
License
Licensed under either of
- Apache License, Version 2.0
- MIT License
at your option.