Skip to main content

HEADER_NODE_API

Constant HEADER_NODE_API 

Source
pub const HEADER_NODE_API: &str = "#include <stddef.h>\n\n/*\n * dora C node API\n *\n * ## Threading model\n *\n * The dora context (returned by init_dora_context_from_env) and any event\n * pointer (returned by dora_next_event) are NOT internally synchronized.\n * Each function below is annotated with its thread-safety contract.\n *\n * Rule of thumb:\n *   - A single context pointer must be accessed by at most one thread at a\n *     time. The dora-cli has not yet stabilized a Sync-safe context, so\n *     calling dora_next_event / dora_send_output / dora_log concurrently\n *     with the same context is undefined behavior.\n *   - Event pointers are read-only after creation, so multiple threads\n *     may read fields from the same event concurrently (each thread\n *     supplying its own out_ptr / out_len storage).\n *   - free_dora_context and free_dora_event take ownership; the caller\n *     must guarantee no other thread is touching the context / event when\n *     free is called.\n *\n * See dora-rs/dora#540 for the audit that produced these annotations.\n */\n\n/* Thread-safe: yes. Creates a fresh dora context from env vars; no shared\n * state at entry. Typically called once at node startup. */\nvoid *init_dora_context_from_env();\n\n/* Thread-safe: NO. Takes ownership of the context and drops it. The caller\n * must guarantee no other thread is using `dora_context` when this is\n * called, and the pointer must not be reused afterward. */\nvoid free_dora_context(void *dora_context);\n\n/* Thread-safe: NO. Mutates the context\'s internal event-stream cursor.\n * Concurrent calls with the same `dora_context` are undefined behavior.\n * If you need to fan out events to worker threads, drain events from a\n * single thread and dispatch by event type. */\nvoid *dora_next_event(void *dora_context);\n\n/* Thread-safe: NO. Takes ownership of `dora_event` and drops it. After\n * freeing, neither the event pointer nor any pointer returned by the\n * read_dora_event_* / read_dora_input_* family for that event may be\n * used. */\nvoid free_dora_event(void *dora_event);\n\nenum DoraEventType\n{\n    DoraEventType_Stop,\n    DoraEventType_Input,\n    DoraEventType_InputClosed,\n    DoraEventType_Error,\n    DoraEventType_Unknown,\n};\n/* Thread-safe: yes (read-only). The returned enum value is by-value; no\n * state is mutated on the event. */\nenum DoraEventType read_dora_event_type(void *dora_event);\n\n/* Thread-safe: yes (read-only on `dora_event`). The caller is responsible\n * for ensuring the `out_ptr` / `out_len` destinations are not aliased by\n * other concurrent calls. */\nvoid read_dora_input_id(void *dora_event, char **out_ptr, size_t *out_len);\n\n/* Thread-safe: yes (read-only on `dora_event`). Same caveat as\n * read_dora_input_id about caller-owned out destinations. */\nvoid read_dora_input_data(void *dora_event, char **out_ptr, size_t *out_len);\n\n/* Thread-safe: yes (read-only). Returns by value. */\nunsigned long long read_dora_input_timestamp(void *dora_event);\n\n/* Thread-safe: NO. Mutates the context\'s internal sender state. Concurrent\n * calls with the same `dora_context` are undefined behavior. */\nint dora_send_output(void *dora_context, const char *id_ptr, size_t id_len, const char *data_ptr, size_t data_len);\n\n/* Thread-safe: NO. Mutates the context\'s internal logger state. Concurrent\n * calls with the same `dora_context` are undefined behavior. */\nint dora_log(void *dora_context, const char *level_ptr, size_t level_len, const char *msg_ptr, size_t msg_len);\n\n/* Backward-compatible aliases for dora-hub C nodes. */\n#define init_dora_context_from_env  init_dora_context_from_env\n#define free_dora_context           free_dora_context\n#define dora_next_event             dora_next_event\n#define free_dora_event             free_dora_event\n#define read_dora_event_type        read_dora_event_type\n#define read_dora_input_id          read_dora_input_id\n#define read_dora_input_data        read_dora_input_data\n#define read_dora_input_timestamp   read_dora_input_timestamp\n#define dora_send_output            dora_send_output\n#define dora_log                    dora_log\n\ntypedef enum DoraEventType DoraEventType;\n#define DoraEventType_Stop        DoraEventType_Stop\n#define DoraEventType_Input       DoraEventType_Input\n#define DoraEventType_InputClosed DoraEventType_InputClosed\n#define DoraEventType_Error       DoraEventType_Error\n#define DoraEventType_Unknown     DoraEventType_Unknown\n";