/* naut_plugin.h - stable versioned native plugin ABI. */ #ifndef NAUT_PLUGIN_H #define NAUT_PLUGIN_H #include "naut/common.h" #include "naut/event.h" #define NAUT_PLUGIN_ABI_VERSION 1u typedef struct { uint32_t abi_version; uint32_t struct_size; const char *name; void *(*open)(const char *root, naut_err *error); void (*close)(void *storage); naut_err (*read)(void *storage, int64_t offset, void *buffer, size_t length); naut_err (*write)(void *storage, int64_t offset, const void *buffer, size_t length); } naut_storage_backend_v1; /* request_json is a JSON object or null. response_json must be malloc-owned * compact JSON on success; the host frees it after parsing. */ typedef naut_err (*naut_plugin_rpc_fn)(void *context, const char *request_json, char **response_json); typedef void (*naut_plugin_event_fn)(void *context, const naut_event *event); typedef struct naut_host_api { uint32_t abi_version; uint32_t struct_size; void *host_context; naut_err (*set_plugin_name)(void *host_context, const char *name); naut_err (*register_rpc)(void *host_context, const char *method, naut_plugin_rpc_fn callback, void *context); naut_err (*register_storage_backend)( void *host_context, const naut_storage_backend_v1 *backend); naut_err (*subscribe_event)(void *host_context, naut_plugin_event_fn callback, void *context); void (*emit_event)(void *host_context, const naut_event *event); void (*log)(void *host_context, int level, const char *message); } naut_host_api; /* Every plugin exports this exact symbol. */ typedef naut_err (*naut_plugin_register_fn)(const naut_host_api *host); #endif /* NAUT_PLUGIN_H */