.TH "bud/bud.h" 3 "bud" \" -*- nroff -*- .ad l .nh .SH NAME bud/bud.h \- HTML tree builder and patch runtime\&. .SH SYNOPSIS .br .PP \fR#include \fP .br \fR#include \fP .br .SS "Data Structures" .in +1c .ti -1c .RI "struct \fBbud_event\fP" .br .RI "A DOM event dispatched through a bud runtime\&. " .ti -1c .RI "struct \fBbud_component\fP" .br .RI "A renderable component\&. " .ti -1c .RI "struct \fBbud_field_desc\fP" .br .RI "One state-field definition driving JSON→state binding\&. " .in -1c .SS "Macros" .in +1c .ti -1c .RI "#define \fBBUD_SRC_FIELDS\fP" .br .RI "Empty placeholder when BUD_DEBUG is not defined\&. " .in -1c .SS "Typedefs" .in +1c .ti -1c .RI "typedef enum \fBbud_node_kind\fP \fBbud_node_kind\fP" .br .RI "Node kinds in a bud tree\&. " .ti -1c .RI "typedef struct \fBbud_node\fP \fBbud_node\fP" .br .RI "Opaque DOM node handle\&. " .ti -1c .RI "typedef struct \fBbud_runtime\fP \fBbud_runtime\fP" .br .RI "Opaque runtime handle managing a node tree lifecycle\&. " .ti -1c .RI "typedef int(* \fBbud_emit_fn\fP) (void *user, const char *op, const char *a, const char *b, const char *c)" .br .RI "Callback invoked per emitted patch operation\&. " .ti -1c .RI "typedef int(* \fBbud_hydrate_lookup_fn\fP) (void *user, unsigned int id, const char **kind, const char **tag, const char **text)" .br .RI "Callback resolving a hydrated node id to its DOM metadata\&. " .ti -1c .RI "typedef void(* \fBbud_runtime_invalidate_fn\fP) (void *user, \fBbud_runtime\fP *runtime)" .br .RI "Callback invoked when the runtime is invalidated\&. " .ti -1c .RI "typedef struct bud_event \fBbud_event\fP" .br .RI "A DOM event dispatched through a bud runtime\&. " .ti -1c .RI "typedef int(* \fBbud_event_handler_fn\fP) (\fBbud_event\fP *event)" .br .RI "Event handler signature\&. " .ti -1c .RI "typedef void(* \fBbud_lifecycle_fn\fP) (void *user, \fBbud_runtime\fP *runtime, const \fBbud_node\fP *node)" .br .RI "Node lifecycle callback\&. " .ti -1c .RI "typedef \fBbud_node\fP *(* \fBbud_component_fn\fP) (void *ctx, const void *props)" .br .RI "Component render function signature\&. " .ti -1c .RI "typedef struct bud_component \fBbud_component\fP" .br .RI "A renderable component\&. " .ti -1c .RI "typedef struct \fBbud_arena\fP \fBbud_arena\fP" .br .RI "Opaque bump-allocator arena for per-render \fBbud_node\fP trees\&. " .ti -1c .RI "typedef struct \fBbud_field_desc\fP \fBbud_field_desc_t\fP" .br .RI "One state-field definition driving JSON→state binding\&. " .in -1c .SS "Enumerations" .in +1c .ti -1c .RI "enum \fBbud_node_kind\fP { \fBBUD_NODE_FRAGMENT\fP = 0, \fBBUD_NODE_ELEMENT\fP = 1, \fBBUD_NODE_TEXT\fP = 2, \fBBUD_NODE_RAW_HTML\fP = 3, \fBBUD_NODE_COMPONENT\fP = 4 }" .br .RI "Node kinds in a bud tree\&. " .in -1c .SS "Functions" .in +1c .ti -1c .RI "\fBbud_node\fP * \fBbud_fragment\fP (void)" .br .RI "Create an empty fragment node\&. " .ti -1c .RI "\fBbud_node\fP * \fBbud_element\fP (const char *tag)" .br .RI "Create an element node\&. " .ti -1c .RI "\fBbud_node\fP * \fBbud_element_lit\fP (const char *tag_lit)" .br .RI "Create an element node with a static-lifetime tag string (zero-copy)\&. " .ti -1c .RI "\fBbud_node\fP * \fBbud_text\fP (const char *text)" .br .RI "Create a text node (HTML-escaped on render)\&. " .ti -1c .RI "\fBbud_node\fP * \fBbud_text_lit\fP (const char *text_lit)" .br .RI "Create a text node with a static-lifetime string (zero-copy)\&. " .ti -1c .RI "\fBbud_node\fP * \fBbud_textf\fP (const char *fmt,\&.\&.\&.)" .br .RI "Create a text node from a printf-style format\&. " .ti -1c .RI "\fBbud_node\fP * \fBbud_hidden_input\fP (const char *name, const char *value)" .br .RI "Create a hidden input element carrying a name/value pair\&. " .ti -1c .RI "\fBbud_node\fP * \fBbud_hidden_input_int\fP (const char *name, int value)" .br .RI "Create a hidden input element carrying an integer value\&. " .ti -1c .RI "\fBbud_node\fP * \fBbud_submit_btn\fP (const char *label, const char *class_name)" .br .RI "Create a submit button element with an optional class\&. " .ti -1c .RI "\fBbud_node\fP * \fBbud_link\fP (const char *href, const char *text, const char *class_name)" .br .RI "Create an anchor element\&. " .ti -1c .RI "\fBbud_node\fP * \fBbud_raw\fP (const char *html)" .br .RI "Create a raw-HTML node emitted verbatim (no escaping)\&. " .ti -1c .RI "\fBbud_node\fP * \fBbud_tpl\fP (const char *fmt,\&.\&.\&.)" .br .RI "Create a raw-HTML node from a printf-style format\&. " .ti -1c .RI "\fBbud_node\fP * \fBbud_vtpl\fP (const char *fmt, va_list ap)" .br .RI "Create a raw-HTML node from a format and va_list\&. " .ti -1c .RI "void \fBbud_raw_set_text\fP (\fBbud_node\fP *node, const char *text)" .br .RI "Replace a raw node's text without touching child nodes\&. " .ti -1c .RI "\fBbud_node\fP * \fBbud_component_render\fP (const \fBbud_component\fP *component, const void *props)" .br .RI "Render a component instance\&. " .ti -1c .RI "int \fBbud_set_attr\fP (\fBbud_node\fP *node, const char *name, const char *value)" .br .RI "Set an attribute on a node\&. " .ti -1c .RI "int \fBbud_set_attr_lit\fP (\fBbud_node\fP *node, const char *name_lit, const char *value_lit)" .br .RI "Set an attribute with static-lifetime name and value (zero-copy)\&. " .ti -1c .RI "int \fBbud_set_attr_name_lit\fP (\fBbud_node\fP *node, const char *name_lit, const char *value)" .br .RI "Set an attribute with a static-lifetime name and copied value\&. " .ti -1c .RI "int \fBbud_set_attr_fmt\fP (\fBbud_node\fP *node, const char *name, const char *fmt,\&.\&.\&.)" .br .RI "Set an attribute from a printf-style format\&. " .ti -1c .RI "int \fBbud_set_bool_attr\fP (\fBbud_node\fP *node, const char *name)" .br .RI "Set a boolean (valueless) attribute on a node\&. " .ti -1c .RI "int \fBbud_set_bool_attr_lit\fP (\fBbud_node\fP *node, const char *name_lit)" .br .RI "Set a boolean attribute with a static-lifetime name (zero-copy)\&. " .ti -1c .RI "const char * \fBbud_get_attr\fP (const \fBbud_node\fP *node, const char *name)" .br .RI "Read an attribute value\&. " .ti -1c .RI "int \fBbud_add_class\fP (\fBbud_node\fP *node, const char *cls)" .br .RI "Add a CSS class to a node\&. " .ti -1c .RI "int \fBbud_remove_class\fP (\fBbud_node\fP *node, const char *cls)" .br .RI "Remove a CSS class from a node\&. " .ti -1c .RI "int \fBbud_toggle_class\fP (\fBbud_node\fP *node, const char *cls)" .br .RI "Toggle a CSS class on a node\&. " .ti -1c .RI "int \fBbud_detach\fP (\fBbud_node\fP *node)" .br .RI "Detach a node from its parent\&. " .ti -1c .RI "int \fBbud_on\fP (\fBbud_node\fP *node, const char *event, int bubbles)" .br .RI "Mark a node as listening for an event\&. " .ti -1c .RI "int \fBbud_bind\fP (\fBbud_node\fP *node, const char *event, int bubbles, \fBbud_event_handler_fn\fP handler)" .br .RI "Bind an event handler to a node\&. " .ti -1c .RI "int \fBbud_bind_ctx\fP (\fBbud_node\fP *node, const char *event, int bubbles, \fBbud_event_handler_fn\fP handler, const void *ctx, size_t ctx_size)" .br .RI "Bind an event handler with optional inline-copied context payload\&. " .ti -1c .RI "int \fBbud_bind_ctx_lit\fP (\fBbud_node\fP *node, const char *event_lit, int bubbles, \fBbud_event_handler_fn\fP handler, const void *ctx, size_t ctx_size)" .br .RI "Bind an event handler with a static-lifetime event name (zero-copy)\&. " .ti -1c .RI "\fBbud_node\fP * \fBbud_component_vnode\fP (\fBbud_component_fn\fP fn, void *ctx, const void *props, size_t props_size)" .br .RI "Create a lazy component virtual node with inline-copied props\&. " .ti -1c .RI "int \fBbud_api_action_handler\fP (\fBbud_event\fP *event)" .br .RI "Dispatch a UI action encoded in the event\&. " .ti -1c .RI "int \fBbud_set_lifecycle\fP (\fBbud_node\fP *node, \fBbud_lifecycle_fn\fP on_mount, \fBbud_lifecycle_fn\fP on_update, \fBbud_lifecycle_fn\fP on_unmount, void *user)" .br .RI "Attach lifecycle callbacks to a node\&. " .ti -1c .RI "int \fBbud_append\fP (\fBbud_node\fP *parent, \fBbud_node\fP *child)" .br .RI "Append a child to a parent node\&. " .ti -1c .RI "\fBbud_node_kind\fP \fBbud_node_kind_of\fP (const \fBbud_node\fP *node)" .br .RI "Kind of a node\&. " .ti -1c .RI "const char * \fBbud_node_tag\fP (const \fBbud_node\fP *node)" .br .RI "Tag name of an element node\&. " .ti -1c .RI "const char * \fBbud_node_text\fP (const \fBbud_node\fP *node)" .br .RI "Text content of a text node\&. " .ti -1c .RI "unsigned int \fBbud_node_id\fP (const \fBbud_node\fP *node)" .br .RI "Stable id of a node\&. " .ti -1c .RI "size_t \fBbud_node_child_count\fP (const \fBbud_node\fP *node)" .br .RI "Number of children of a node\&. " .ti -1c .RI "const \fBbud_node\fP * \fBbud_node_child\fP (const \fBbud_node\fP *node, size_t index)" .br .RI "Child at an index\&. " .ti -1c .RI "\fBbud_node\fP * \fBbud_node_parent\fP (const \fBbud_node\fP *node)" .br .RI "Parent of a node\&. " .ti -1c .RI "size_t \fBbud_node_attr_count\fP (const \fBbud_node\fP *node)" .br .RI "Number of attributes on a node\&. " .ti -1c .RI "const char * \fBbud_node_attr_name\fP (const \fBbud_node\fP *node, size_t index)" .br .RI "Attribute name at an index\&. " .ti -1c .RI "const char * \fBbud_node_attr_value\fP (const \fBbud_node\fP *node, size_t index)" .br .RI "Attribute value at an index\&. " .ti -1c .RI "size_t \fBbud_node_listener_count\fP (const \fBbud_node\fP *node)" .br .RI "Number of listeners on a node\&. " .ti -1c .RI "const char * \fBbud_node_listener_event\fP (const \fBbud_node\fP *node, size_t index)" .br .RI "Event type of a listener at an index\&. " .ti -1c .RI "int \fBbud_node_listener_bubbles\fP (const \fBbud_node\fP *node, size_t index)" .br .RI "Bubble flag of a listener at an index\&. " .ti -1c .RI "\fBbud_node\fP * \fBbud_expand_tree\fP (\fBbud_node\fP *root)" .br .RI "Recursively expand all BUD_NODE_COMPONENT nodes in a tree in-place\&. " .ti -1c .RI "char * \fBbud_render_html\fP (const \fBbud_node\fP *root)" .br .RI "Render a node tree to HTML\&. " .ti -1c .RI "char * \fBbud_render_hydrated_html\fP (const \fBbud_node\fP *root)" .br .RI "Render a node tree to hydration HTML with data-hook ids\&. " .ti -1c .RI "int \fBbud_render_ops\fP (const \fBbud_node\fP *root, \fBbud_emit_fn\fP emit, void *user)" .br .RI "Emit patch operations for a full render\&. " .ti -1c .RI "int \fBbud_render_hydration_ops\fP (const \fBbud_node\fP *root, \fBbud_emit_fn\fP emit, void *user)" .br .RI "Emit hydration operations for a fresh mount\&. " .ti -1c .RI "int \fBbud_render_patch_ops\fP (const \fBbud_node\fP *root, \fBbud_emit_fn\fP emit, void *user)" .br .RI "Emit patch operations to bring a server-rendered tree up to date\&. " .ti -1c .RI "int \fBbud_vdom_diff\fP (\fBbud_node\fP *old_root, \fBbud_node\fP *new_root, \fBbud_emit_fn\fP emit, void *user)" .br .RI "Diff two trees and emit minimal patch operations\&. " .ti -1c .RI "void \fBbud_app_set_state\fP (void)" .br .RI "Signal that application state has changed (triggers re-render)\&. " .ti -1c .RI "int \fBbud_hydrate\fP (const \fBbud_node\fP *root, \fBbud_hydrate_lookup_fn\fP lookup, void *user)" .br .RI "Hydrate a server-rendered tree into DOM nodes\&. " .ti -1c .RI "\fBbud_runtime\fP * \fBbud_runtime_new\fP (\fBbud_node\fP *root)" .br .RI "Create a runtime owning a node tree\&. " .ti -1c .RI "void \fBbud_runtime_free\fP (\fBbud_runtime\fP *runtime)" .br .RI "Free a runtime and its tree\&. " .ti -1c .RI "\fBbud_node\fP * \fBbud_runtime_root\fP (const \fBbud_runtime\fP *runtime)" .br .RI "Root node of a runtime\&. " .ti -1c .RI "int \fBbud_runtime_set_invalidate\fP (\fBbud_runtime\fP *runtime, \fBbud_runtime_invalidate_fn\fP fn, void *user)" .br .RI "Install an invalidation callback on a runtime\&. " .ti -1c .RI "int \fBbud_runtime_mark_dirty\fP (\fBbud_runtime\fP *runtime)" .br .RI "Mark a runtime dirty\&. " .ti -1c .RI "int \fBbud_runtime_is_dirty\fP (const \fBbud_runtime\fP *runtime)" .br .RI "Query whether a runtime is dirty\&. " .ti -1c .RI "int \fBbud_runtime_flush\fP (\fBbud_runtime\fP *runtime)" .br .RI "Flush pending patch operations\&. " .ti -1c .RI "int \fBbud_runtime_mount\fP (\fBbud_runtime\fP *runtime)" .br .RI "Mount the runtime root into the live document\&. " .ti -1c .RI "int \fBbud_runtime_update\fP (\fBbud_runtime\fP *runtime)" .br .RI "Apply a full update pass\&. " .ti -1c .RI "int \fBbud_runtime_unmount\fP (\fBbud_runtime\fP *runtime)" .br .RI "Unmount the runtime root\&. " .ti -1c .RI "int \fBbud_runtime_dispatch\fP (\fBbud_runtime\fP *runtime, \fBbud_node\fP *target, const char *event, void *event_user)" .br .RI "Dispatch an event through a runtime\&. " .ti -1c .RI "void \fBbud_event_stop_propagation\fP (\fBbud_event\fP *event)" .br .RI "Stop an event from propagating further\&. " .ti -1c .RI "void \fBbud_event_prevent_default\fP (\fBbud_event\fP *event)" .br .RI "Prevent an event's default action\&. " .ti -1c .RI "void \fBbud_free\fP (\fBbud_node\fP *node)" .br .RI "Free a node tree\&. " .ti -1c .RI "void \fBbud_free_string\fP (char *value)" .br .RI "Free a string returned by a bud_render_* function\&. " .ti -1c .RI "\fBbud_arena\fP * \fBbud_arena_new\fP (size_t initial_cap)" .br .RI "Create a new bump arena\&. " .ti -1c .RI "\fBbud_arena\fP * \fBbud_arena_push\fP (\fBbud_arena\fP *arena)" .br .RI "Activate an arena for subsequent \fBbud_node\fP allocations on this thread\&. " .ti -1c .RI "void \fBbud_arena_pop\fP (\fBbud_arena\fP *prev)" .br .RI "Restore the previously active arena returned by \fBbud_arena_push()\fP\&. " .ti -1c .RI "\fBbud_arena\fP * \fBbud_arena_current\fP (void)" .br .RI "Return the currently active arena on this thread, or NULL\&. " .ti -1c .RI "void \fBbud_arena_reset\fP (\fBbud_arena\fP *arena)" .br .RI "Reset an arena for reuse, invalidating all nodes allocated from it\&. " .ti -1c .RI "void \fBbud_arena_free\fP (\fBbud_arena\fP *arena)" .br .RI "Free an arena and all slabs it owns\&. " .ti -1c .RI "size_t \fBbud_arena_bytes_used\fP (const \fBbud_arena\fP *arena)" .br .RI "Return total bytes bumped from the arena since creation or last reset\&. " .ti -1c .RI "void \fBbud_json_str\fP (const char *json, const char *key, char *out, size_t out_size)" .br .RI "Extract a string field from NUL-terminated JSON\&. " .ti -1c .RI "void \fBbud_json_str_len\fP (const char *json, size_t len, const char *key, char *out, size_t out_size)" .br .RI "Extract a string field from length-bounded JSON\&. " .ti -1c .RI "int \fBbud_json_int\fP (const char *json, const char *key, int default_val)" .br .RI "Extract an integer field from NUL-terminated JSON\&. " .ti -1c .RI "int \fBbud_json_int_len\fP (const char *json, size_t len, const char *key, int default_val)" .br .RI "Extract an integer field from length-bounded JSON\&. " .ti -1c .RI "void \fBbud_json_data\fP (const char *json, char *out, size_t out_size)" .br .RI "Extract the raw "data" string field from NUL-terminated JSON\&. " .ti -1c .RI "void \fBbud_json_data_len\fP (const char *json, size_t len, char *out, size_t out_size)" .br .RI "Extract the raw "data" string field from length-bounded JSON\&. " .ti -1c .RI "int \fBbud_json_array_for_each\fP (const char *json, void(*fn)(const char *elem, size_t len, void *user), void *user)" .br .RI "Iterate over a top-level JSON array (NUL-terminated)\&. " .ti -1c .RI "int \fBbud_json_array_for_each_len\fP (const char *json, size_t len, void(*fn)(const char *elem, size_t len, void *user), void *user)" .br .RI "Iterate over a top-level JSON array (length-bounded)\&. " .ti -1c .RI "int \fBbud_json_array_for_each_key_len\fP (const char *json, size_t len, const char *key, void(*fn)(const char *elem, size_t len, void *user), void *user)" .br .RI "Iterate over the array stored under a named key\&. " .ti -1c .RI "void \fBbud_state_apply\fP (void *state, const \fBbud_field_desc_t\fP *fields, const char *json)" .br .RI "Apply JSON fields onto a state struct (fully flexible)\&. " .ti -1c .RI "void \fBbud_state_apply_len\fP (void *state, const \fBbud_field_desc_t\fP *fields, const char *json, size_t len)" .br .RI "Apply length-bounded JSON fields onto a state struct\&. " .ti -1c .RI "void \fBbud_state_apply_stride\fP (void *state, const void *fields, size_t field_stride, const char *json)" .br .RI "Apply JSON onto a state struct with caller-specified field stride\&. " .ti -1c .RI "void \fBbud_state_apply_stride_len\fP (void *state, const void *fields, size_t field_stride, const char *json, size_t len)" .br .RI "Apply length-bounded JSON with caller-specified field stride\&. " .ti -1c .RI "void \fBbud_state_apply_array\fP (const char *json, const char *key, void *array_out, size_t elem_size, int *count_out, int max_elems, const \fBbud_field_desc_t\fP *schema)" .br .RI "Populate a fixed-capacity array from a JSON array field\&. " .ti -1c .RI "void \fBbud_state_apply_array_len\fP (const char *json, size_t len, const char *key, void *array_out, size_t elem_size, int *count_out, int max_elems, const \fBbud_field_desc_t\fP *schema)" .br .RI "Populate a fixed-capacity array from a length-bounded JSON array\&. " .ti -1c .RI "void \fBbud_state_apply_array_stride_len\fP (const char *json, size_t len, const char *key, void *array_out, size_t elem_size, int *count_out, int max_elems, const void *schema, size_t schema_stride)" .br .RI "Populate a fixed-capacity array with caller-specified schema stride\&. " .ti -1c .RI "void \fBbud_node_set_src\fP (\fBbud_node\fP *node, const char *file, int line)" .br .RI "Stamp a debug source location onto a node\&. " .ti -1c .RI "const char * \fBbud_node_get_src\fP (const \fBbud_node\fP *node)" .br .RI "Read a node's stamped source file\&. " .ti -1c .RI "int \fBbud_sprint_tree\fP (const \fBbud_node\fP *root, char *buf, size_t bufsz)" .br .RI "Render a compact ASCII tree dump for debugging\&. " .in -1c .SH "Detailed Description" .PP HTML tree builder and patch runtime\&. Builds DOM nodes in C and reconciles them against a live document via minimal patch operations; pure and isomorphic (SSR + WASM)\&. .SH "Typedef Documentation" .PP .SS "typedef struct \fBbud_arena\fP \fBbud_arena\fP" .PP Opaque bump-allocator arena for per-render \fBbud_node\fP trees\&. While pushed via \fBbud_arena_push()\fP, node/attr/listener/props/string allocations are bumped from contiguous growing slabs rather than individual malloc/calloc calls\&. Calling \fBbud_arena_reset()\fP or \fBbud_arena_free()\fP tears down the entire tree in O(slabs) without walking nodes\&. Calling \fBbud_free()\fP on arena nodes remains safe (lifecycle unmount runs; arena slabs stay intact)\&. .SS "typedef \fBbud_node\fP *(* bud_component_fn) (void *ctx, const void *props)" .PP Component render function signature\&. .PP \fBParameters\fP .RS 4 \fIctx\fP Component context\&. .br \fIprops\fP Immutable props\&. .RE .PP \fBReturns\fP .RS 4 The rendered node subtree\&. .RE .PP .SS "typedef int(* bud_emit_fn) (void *user, const char *op, const char *a, const char *b, const char *c)" .PP Callback invoked per emitted patch operation\&. .PP \fBParameters\fP .RS 4 \fIuser\fP Arbitrary caller data\&. .br \fIop\fP Operation name (e\&.g\&. "append", "set_attr")\&. .br \fIa\fP First operand\&. .br \fIb\fP Second operand\&. .br \fIc\fP Third operand\&. .RE .PP \fBReturns\fP .RS 4 Non-zero to abort emission\&. .RE .PP .SS "typedef int(* bud_event_handler_fn) (\fBbud_event\fP *event)" .PP Event handler signature\&. .PP \fBParameters\fP .RS 4 \fIevent\fP Event being dispatched\&. .RE .PP \fBReturns\fP .RS 4 Non-zero to stop propagation\&. .RE .PP .SS "typedef int(* bud_hydrate_lookup_fn) (void *user, unsigned int id, const char **kind, const char **tag, const char **text)" .PP Callback resolving a hydrated node id to its DOM metadata\&. .PP \fBParameters\fP .RS 4 \fIuser\fP Arbitrary caller data\&. .br \fIid\fP Node id\&. .br \fIkind\fP Receives the node kind\&. .br \fItag\fP Receives the element tag\&. .br \fItext\fP Receives the text content\&. .RE .PP \fBReturns\fP .RS 4 Non-zero on success\&. .RE .PP .SS "typedef void(* bud_lifecycle_fn) (void *user, \fBbud_runtime\fP *runtime, const \fBbud_node\fP *node)" .PP Node lifecycle callback\&. .PP \fBParameters\fP .RS 4 \fIuser\fP Arbitrary caller data\&. .br \fIruntime\fP Owning runtime\&. .br \fInode\fP Node entering/leaving the tree\&. .RE .PP .SS "typedef void(* bud_runtime_invalidate_fn) (void *user, \fBbud_runtime\fP *runtime)" .PP Callback invoked when the runtime is invalidated\&. .PP \fBParameters\fP .RS 4 \fIuser\fP Arbitrary caller data\&. .br \fIruntime\fP Invalidated runtime\&. .RE .PP .SH "Enumeration Type Documentation" .PP .SS "enum \fBbud_node_kind\fP" .PP Node kinds in a bud tree\&. .PP \fBEnumerator\fP .in +1c .TP \f(BIBUD_NODE_FRAGMENT \fP Document fragment grouping child nodes without an element wrapper\&. .TP \f(BIBUD_NODE_ELEMENT \fP Element node with a tag name\&. .TP \f(BIBUD_NODE_TEXT \fP Text node whose contents are HTML-escaped on render\&. .TP \f(BIBUD_NODE_RAW_HTML \fP Raw HTML node emitted verbatim without escaping\&. .TP \f(BIBUD_NODE_COMPONENT \fP Lazy component node expanded on reconcile or SSR\&. .SH "Function Documentation" .PP .SS "int bud_add_class (\fBbud_node\fP * node, const char * cls)" .PP Add a CSS class to a node\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .br \fIcls\fP Class name\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "int bud_api_action_handler (\fBbud_event\fP * event)" .PP Dispatch a UI action encoded in the event\&. .PP \fBParameters\fP .RS 4 \fIevent\fP Event to dispatch\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "int bud_append (\fBbud_node\fP * parent, \fBbud_node\fP * child)" .PP Append a child to a parent node\&. .PP \fBParameters\fP .RS 4 \fIparent\fP Parent node\&. .br \fIchild\fP Child node\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "void bud_arena_free (\fBbud_arena\fP * arena)" .PP Free an arena and all slabs it owns\&. .PP \fBParameters\fP .RS 4 \fIarena\fP Target arena (NULL is a no-op)\&. .RE .PP .SS "\fBbud_arena\fP * bud_arena_new (size_t initial_cap)" .PP Create a new bump arena\&. .PP \fBParameters\fP .RS 4 \fIinitial_cap\fP Initial slab capacity in bytes (0 = default 8192)\&. .RE .PP \fBReturns\fP .RS 4 New arena, or NULL on allocation failure\&. .RE .PP .SS "void bud_arena_pop (\fBbud_arena\fP * prev)" .PP Restore the previously active arena returned by \fBbud_arena_push()\fP\&. .PP \fBParameters\fP .RS 4 \fIprev\fP Arena pointer returned by the matching \fBbud_arena_push()\fP\&. .RE .PP .SS "\fBbud_arena\fP * bud_arena_push (\fBbud_arena\fP * arena)" .PP Activate an arena for subsequent \fBbud_node\fP allocations on this thread\&. .PP \fBParameters\fP .RS 4 \fIarena\fP Arena to activate (or NULL to allocate from heap)\&. .RE .PP \fBReturns\fP .RS 4 Previously active arena (pass to \fBbud_arena_pop()\fP to restore)\&. .RE .PP .SS "void bud_arena_reset (\fBbud_arena\fP * arena)" .PP Reset an arena for reuse, invalidating all nodes allocated from it\&. .PP \fBParameters\fP .RS 4 \fIarena\fP Target arena (NULL is a no-op)\&. .RE .PP .SS "int bud_bind (\fBbud_node\fP * node, const char * event, int bubbles, \fBbud_event_handler_fn\fP handler)" .PP Bind an event handler to a node\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .br \fIevent\fP Event type\&. .br \fIbubbles\fP Non-zero to bubble\&. .br \fIhandler\fP Handler callback\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "int bud_bind_ctx (\fBbud_node\fP * node, const char * event, int bubbles, \fBbud_event_handler_fn\fP handler, const void * ctx, size_t ctx_size)" .PP Bind an event handler with optional inline-copied context payload\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .br \fIevent\fP Event type\&. .br \fIbubbles\fP Non-zero to bubble\&. .br \fIhandler\fP Handler callback\&. .br \fIctx\fP Context payload pointer (may be NULL)\&. .br \fIctx_size\fP Byte size to copy inline (0 to store ctx pointer as-is)\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "\fBbud_node\fP * bud_component_render (const \fBbud_component\fP * component, const void * props)" .PP Render a component instance\&. .PP \fBParameters\fP .RS 4 \fIcomponent\fP Component to render\&. .br \fIprops\fP Immutable props\&. .RE .PP \fBReturns\fP .RS 4 Rendered node subtree\&. .RE .PP .SS "\fBbud_node\fP * bud_component_vnode (\fBbud_component_fn\fP fn, void * ctx, const void * props, size_t props_size)" .PP Create a lazy component virtual node with inline-copied props\&. .PP \fBParameters\fP .RS 4 \fIfn\fP Component render function\&. .br \fIctx\fP Optional component context pointer\&. .br \fIprops\fP Pointer to props struct (may be stack-allocated or NULL)\&. .br \fIprops_size\fP Byte size of props struct (0 when props is NULL)\&. .RE .PP \fBReturns\fP .RS 4 New component node, or NULL on allocation failure\&. .RE .PP .SS "int bud_detach (\fBbud_node\fP * node)" .PP Detach a node from its parent\&. .PP \fBParameters\fP .RS 4 \fInode\fP Node to detach\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "\fBbud_node\fP * bud_element (const char * tag)" .PP Create an element node\&. .PP \fBParameters\fP .RS 4 \fItag\fP Element tag name\&. .RE .PP \fBReturns\fP .RS 4 New element node\&. .RE .PP .SS "\fBbud_node\fP * bud_element_lit (const char * tag_lit)" .PP Create an element node with a static-lifetime tag string (zero-copy)\&. .PP \fBParameters\fP .RS 4 \fItag_lit\fP Static string literal tag name (not copied or freed)\&. .RE .PP \fBReturns\fP .RS 4 New element node\&. .RE .PP .SS "void bud_event_prevent_default (\fBbud_event\fP * event)" .PP Prevent an event's default action\&. .PP \fBParameters\fP .RS 4 \fIevent\fP Event to cancel\&. .RE .PP .SS "void bud_event_stop_propagation (\fBbud_event\fP * event)" .PP Stop an event from propagating further\&. .PP \fBParameters\fP .RS 4 \fIevent\fP Event to stop\&. .RE .PP .SS "\fBbud_node\fP * bud_expand_tree (\fBbud_node\fP * root)" .PP Recursively expand all BUD_NODE_COMPONENT nodes in a tree in-place\&. Takes ownership of \fRroot\fP (freeing replaced component shells) and returns the expanded root node, or NULL if a root component expands to NULL\&. .PP \fBParameters\fP .RS 4 \fIroot\fP Root node of the tree to expand\&. .RE .PP \fBReturns\fP .RS 4 Expanded root node, or NULL\&. .RE .PP .SS "\fBbud_node\fP * bud_fragment (void )" .PP Create an empty fragment node\&. .PP \fBReturns\fP .RS 4 New fragment node\&. .RE .PP .SS "void bud_free (\fBbud_node\fP * node)" .PP Free a node tree\&. .PP \fBParameters\fP .RS 4 \fInode\fP Root node to free\&. .RE .PP .SS "void bud_free_string (char * value)" .PP Free a string returned by a bud_render_* function\&. .PP \fBParameters\fP .RS 4 \fIvalue\fP String to free\&. .RE .PP .SS "const char * bud_get_attr (const \fBbud_node\fP * node, const char * name)" .PP Read an attribute value\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .br \fIname\fP Attribute name\&. .RE .PP \fBReturns\fP .RS 4 Attribute value, or NULL when absent\&. .RE .PP .SS "\fBbud_node\fP * bud_hidden_input (const char * name, const char * value)" .PP Create a hidden input element carrying a name/value pair\&. .PP \fBParameters\fP .RS 4 \fIname\fP Input name\&. .br \fIvalue\fP Input value\&. .RE .PP \fBReturns\fP .RS 4 New input element node\&. .RE .PP .SS "\fBbud_node\fP * bud_hidden_input_int (const char * name, int value)" .PP Create a hidden input element carrying an integer value\&. .PP \fBParameters\fP .RS 4 \fIname\fP Input name\&. .br \fIvalue\fP Integer value (serialized as text)\&. .RE .PP \fBReturns\fP .RS 4 New input element node\&. .RE .PP .SS "int bud_hydrate (const \fBbud_node\fP * root, \fBbud_hydrate_lookup_fn\fP lookup, void * user)" .PP Hydrate a server-rendered tree into DOM nodes\&. .PP \fBParameters\fP .RS 4 \fIroot\fP Root node\&. .br \fIlookup\fP Hydration lookup callback\&. .br \fIuser\fP Caller data passed to lookup\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "int bud_json_array_for_each (const char * json, void(* fn )(const char *elem, size_t len, void *user), void * user)" .PP Iterate over a top-level JSON array (NUL-terminated)\&. .PP \fBParameters\fP .RS 4 \fIjson\fP NUL-terminated JSON array\&. .br \fIfn\fP Callback per element (borrowed, length-bounded)\&. .br \fIuser\fP Caller data passed to fn\&. .RE .PP \fBReturns\fP .RS 4 Number of elements visited, or -1 on parse failure\&. .RE .PP .SS "int bud_json_array_for_each_key_len (const char * json, size_t len, const char * key, void(* fn )(const char *elem, size_t len, void *user), void * user)" .PP Iterate over the array stored under a named key\&. .PP \fBParameters\fP .RS 4 \fIjson\fP JSON bytes\&. .br \fIlen\fP Byte length of json\&. .br \fIkey\fP Field name holding the array\&. .br \fIfn\fP Callback per element (borrowed, length-bounded)\&. .br \fIuser\fP Caller data passed to fn\&. .RE .PP \fBReturns\fP .RS 4 Number of elements visited, or -1 on parse failure\&. .RE .PP .SS "int bud_json_array_for_each_len (const char * json, size_t len, void(* fn )(const char *elem, size_t len, void *user), void * user)" .PP Iterate over a top-level JSON array (length-bounded)\&. .PP \fBParameters\fP .RS 4 \fIjson\fP JSON array bytes\&. .br \fIlen\fP Byte length of json\&. .br \fIfn\fP Callback per element (borrowed, length-bounded)\&. .br \fIuser\fP Caller data passed to fn\&. .RE .PP \fBReturns\fP .RS 4 Number of elements visited, or -1 on parse failure\&. .RE .PP .SS "void bud_json_data (const char * json, char * out, size_t out_size)" .PP Extract the raw "data" string field from NUL-terminated JSON\&. .PP \fBParameters\fP .RS 4 \fIjson\fP NUL-terminated JSON\&. .br \fIout\fP Destination buffer\&. .br \fIout_size\fP Capacity of out\&. .RE .PP .SS "void bud_json_data_len (const char * json, size_t len, char * out, size_t out_size)" .PP Extract the raw "data" string field from length-bounded JSON\&. .PP \fBParameters\fP .RS 4 \fIjson\fP JSON bytes\&. .br \fIlen\fP Byte length of json\&. .br \fIout\fP Destination buffer\&. .br \fIout_size\fP Capacity of out\&. .RE .PP .SS "int bud_json_int (const char * json, const char * key, int default_val)" .PP Extract an integer field from NUL-terminated JSON\&. .PP \fBParameters\fP .RS 4 \fIjson\fP NUL-terminated JSON\&. .br \fIkey\fP Field name\&. .br \fIdefault_val\fP Value when the field is absent or not an integer\&. .RE .PP \fBReturns\fP .RS 4 Parsed integer\&. .RE .PP .SS "int bud_json_int_len (const char * json, size_t len, const char * key, int default_val)" .PP Extract an integer field from length-bounded JSON\&. .PP \fBParameters\fP .RS 4 \fIjson\fP JSON bytes\&. .br \fIlen\fP Byte length of json\&. .br \fIkey\fP Field name\&. .br \fIdefault_val\fP Value when the field is absent or not an integer\&. .RE .PP \fBReturns\fP .RS 4 Parsed integer\&. .RE .PP .SS "void bud_json_str (const char * json, const char * key, char * out, size_t out_size)" .PP Extract a string field from NUL-terminated JSON\&. .PP \fBParameters\fP .RS 4 \fIjson\fP NUL-terminated JSON\&. .br \fIkey\fP Field name\&. .br \fIout\fP Destination buffer\&. .br \fIout_size\fP Capacity of out (NUL-terminated when > 0)\&. .RE .PP .SS "void bud_json_str_len (const char * json, size_t len, const char * key, char * out, size_t out_size)" .PP Extract a string field from length-bounded JSON\&. .PP \fBParameters\fP .RS 4 \fIjson\fP JSON bytes\&. .br \fIlen\fP Byte length of json\&. .br \fIkey\fP Field name\&. .br \fIout\fP Destination buffer\&. .br \fIout_size\fP Capacity of out (NUL-terminated when > 0)\&. .RE .PP .SS "\fBbud_node\fP * bud_link (const char * href, const char * text, const char * class_name)" .PP Create an anchor element\&. .PP \fBParameters\fP .RS 4 \fIhref\fP Target URL\&. .br \fItext\fP Link text\&. .br \fIclass_name\fP CSS class, or NULL\&. .RE .PP \fBReturns\fP .RS 4 New anchor element node\&. .RE .PP .SS "size_t bud_node_attr_count (const \fBbud_node\fP * node)" .PP Number of attributes on a node\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .RE .PP \fBReturns\fP .RS 4 Attribute count\&. .RE .PP .SS "const char * bud_node_attr_name (const \fBbud_node\fP * node, size_t index)" .PP Attribute name at an index\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .br \fIindex\fP Attribute index\&. .RE .PP \fBReturns\fP .RS 4 Attribute name\&. .RE .PP .SS "const char * bud_node_attr_value (const \fBbud_node\fP * node, size_t index)" .PP Attribute value at an index\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .br \fIindex\fP Attribute index\&. .RE .PP \fBReturns\fP .RS 4 Attribute value\&. .RE .PP .SS "const \fBbud_node\fP * bud_node_child (const \fBbud_node\fP * node, size_t index)" .PP Child at an index\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .br \fIindex\fP Child index\&. .RE .PP \fBReturns\fP .RS 4 Child node, or NULL when out of range\&. .RE .PP .SS "size_t bud_node_child_count (const \fBbud_node\fP * node)" .PP Number of children of a node\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .RE .PP \fBReturns\fP .RS 4 Child count\&. .RE .PP .SS "const char * bud_node_get_src (const \fBbud_node\fP * node)" .PP Read a node's stamped source file\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .RE .PP \fBReturns\fP .RS 4 Source file name, or NULL\&. .RE .PP .SS "unsigned int bud_node_id (const \fBbud_node\fP * node)" .PP Stable id of a node\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .RE .PP \fBReturns\fP .RS 4 Node id\&. .RE .PP .SS "\fBbud_node_kind\fP bud_node_kind_of (const \fBbud_node\fP * node)" .PP Kind of a node\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .RE .PP \fBReturns\fP .RS 4 Node kind\&. .RE .PP .SS "int bud_node_listener_bubbles (const \fBbud_node\fP * node, size_t index)" .PP Bubble flag of a listener at an index\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .br \fIindex\fP Listener index\&. .RE .PP \fBReturns\fP .RS 4 Non-zero when the listener bubbles\&. .RE .PP .SS "size_t bud_node_listener_count (const \fBbud_node\fP * node)" .PP Number of listeners on a node\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .RE .PP \fBReturns\fP .RS 4 Listener count\&. .RE .PP .SS "const char * bud_node_listener_event (const \fBbud_node\fP * node, size_t index)" .PP Event type of a listener at an index\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .br \fIindex\fP Listener index\&. .RE .PP \fBReturns\fP .RS 4 Event type\&. .RE .PP .SS "\fBbud_node\fP * bud_node_parent (const \fBbud_node\fP * node)" .PP Parent of a node\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .RE .PP \fBReturns\fP .RS 4 Parent node, or NULL for roots\&. .RE .PP .SS "void bud_node_set_src (\fBbud_node\fP * node, const char * file, int line)" .PP Stamp a debug source location onto a node\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .br \fIfile\fP Source file name\&. .br \fIline\fP Source line number\&. .RE .PP .SS "const char * bud_node_tag (const \fBbud_node\fP * node)" .PP Tag name of an element node\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .RE .PP \fBReturns\fP .RS 4 Tag name, or NULL for non-elements\&. .RE .PP .SS "const char * bud_node_text (const \fBbud_node\fP * node)" .PP Text content of a text node\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .RE .PP \fBReturns\fP .RS 4 Text, or NULL for non-text nodes\&. .RE .PP .SS "int bud_on (\fBbud_node\fP * node, const char * event, int bubbles)" .PP Mark a node as listening for an event\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .br \fIevent\fP Event type\&. .br \fIbubbles\fP Non-zero to bubble\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "\fBbud_node\fP * bud_raw (const char * html)" .PP Create a raw-HTML node emitted verbatim (no escaping)\&. .PP \fBParameters\fP .RS 4 \fIhtml\fP Raw markup\&. .RE .PP \fBReturns\fP .RS 4 New raw-HTML node\&. .RE .PP .SS "void bud_raw_set_text (\fBbud_node\fP * node, const char * text)" .PP Replace a raw node's text without touching child nodes\&. .PP \fBParameters\fP .RS 4 \fInode\fP Root node\&. .br \fItext\fP Replacement text\&. .RE .PP .SS "int bud_remove_class (\fBbud_node\fP * node, const char * cls)" .PP Remove a CSS class from a node\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .br \fIcls\fP Class name\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "char * bud_render_html (const \fBbud_node\fP * root)" .PP Render a node tree to HTML\&. .PP \fBParameters\fP .RS 4 \fIroot\fP Root node\&. .RE .PP \fBReturns\fP .RS 4 malloc'd HTML string (free with bud_free_string), or NULL\&. .RE .PP .SS "char * bud_render_hydrated_html (const \fBbud_node\fP * root)" .PP Render a node tree to hydration HTML with data-hook ids\&. .PP \fBParameters\fP .RS 4 \fIroot\fP Root node\&. .RE .PP \fBReturns\fP .RS 4 malloc'd HTML string, or NULL\&. .RE .PP .SS "int bud_render_hydration_ops (const \fBbud_node\fP * root, \fBbud_emit_fn\fP emit, void * user)" .PP Emit hydration operations for a fresh mount\&. .PP \fBParameters\fP .RS 4 \fIroot\fP Root node\&. .br \fIemit\fP Emission callback\&. .br \fIuser\fP Caller data passed to emit\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "int bud_render_ops (const \fBbud_node\fP * root, \fBbud_emit_fn\fP emit, void * user)" .PP Emit patch operations for a full render\&. .PP \fBParameters\fP .RS 4 \fIroot\fP Root node\&. .br \fIemit\fP Emission callback\&. .br \fIuser\fP Caller data passed to emit\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "int bud_render_patch_ops (const \fBbud_node\fP * root, \fBbud_emit_fn\fP emit, void * user)" .PP Emit patch operations to bring a server-rendered tree up to date\&. .PP \fBParameters\fP .RS 4 \fIroot\fP Root node\&. .br \fIemit\fP Emission callback\&. .br \fIuser\fP Caller data passed to emit\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "int bud_runtime_dispatch (\fBbud_runtime\fP * runtime, \fBbud_node\fP * target, const char * event, void * event_user)" .PP Dispatch an event through a runtime\&. .PP \fBParameters\fP .RS 4 \fIruntime\fP Target runtime\&. .br \fItarget\fP Receiving node\&. .br \fIevent\fP Event type\&. .br \fIevent_user\fP Caller data attached to the event\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "int bud_runtime_flush (\fBbud_runtime\fP * runtime)" .PP Flush pending patch operations\&. .PP \fBParameters\fP .RS 4 \fIruntime\fP Target runtime\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "void bud_runtime_free (\fBbud_runtime\fP * runtime)" .PP Free a runtime and its tree\&. .PP \fBParameters\fP .RS 4 \fIruntime\fP Runtime to free\&. .RE .PP .SS "int bud_runtime_is_dirty (const \fBbud_runtime\fP * runtime)" .PP Query whether a runtime is dirty\&. .PP \fBParameters\fP .RS 4 \fIruntime\fP Target runtime\&. .RE .PP \fBReturns\fP .RS 4 Non-zero when dirty\&. .RE .PP .SS "int bud_runtime_mark_dirty (\fBbud_runtime\fP * runtime)" .PP Mark a runtime dirty\&. .PP \fBParameters\fP .RS 4 \fIruntime\fP Target runtime\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "int bud_runtime_mount (\fBbud_runtime\fP * runtime)" .PP Mount the runtime root into the live document\&. .PP \fBParameters\fP .RS 4 \fIruntime\fP Target runtime\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "\fBbud_runtime\fP * bud_runtime_new (\fBbud_node\fP * root)" .PP Create a runtime owning a node tree\&. .PP \fBParameters\fP .RS 4 \fIroot\fP Root node\&. .RE .PP \fBReturns\fP .RS 4 New runtime\&. .RE .PP .SS "\fBbud_node\fP * bud_runtime_root (const \fBbud_runtime\fP * runtime)" .PP Root node of a runtime\&. .PP \fBParameters\fP .RS 4 \fIruntime\fP Target runtime\&. .RE .PP \fBReturns\fP .RS 4 Root node\&. .RE .PP .SS "int bud_runtime_set_invalidate (\fBbud_runtime\fP * runtime, \fBbud_runtime_invalidate_fn\fP fn, void * user)" .PP Install an invalidation callback on a runtime\&. .PP \fBParameters\fP .RS 4 \fIruntime\fP Target runtime\&. .br \fIfn\fP Callback, or NULL to clear\&. .br \fIuser\fP Caller data passed to fn\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "int bud_runtime_unmount (\fBbud_runtime\fP * runtime)" .PP Unmount the runtime root\&. .PP \fBParameters\fP .RS 4 \fIruntime\fP Target runtime\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "int bud_runtime_update (\fBbud_runtime\fP * runtime)" .PP Apply a full update pass\&. .PP \fBParameters\fP .RS 4 \fIruntime\fP Target runtime\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "int bud_set_attr (\fBbud_node\fP * node, const char * name, const char * value)" .PP Set an attribute on a node\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .br \fIname\fP Attribute name\&. .br \fIvalue\fP Attribute value\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "int bud_set_attr_fmt (\fBbud_node\fP * node, const char * name, const char * fmt, \&.\&.\&.)" .PP Set an attribute from a printf-style format\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .br \fIname\fP Attribute name\&. .br \fIfmt\fP Format string\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "int bud_set_bool_attr (\fBbud_node\fP * node, const char * name)" .PP Set a boolean (valueless) attribute on a node\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .br \fIname\fP Attribute name\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "int bud_set_lifecycle (\fBbud_node\fP * node, \fBbud_lifecycle_fn\fP on_mount, \fBbud_lifecycle_fn\fP on_update, \fBbud_lifecycle_fn\fP on_unmount, void * user)" .PP Attach lifecycle callbacks to a node\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .br \fIon_mount\fP Mount callback, or NULL\&. .br \fIon_update\fP Update callback, or NULL\&. .br \fIon_unmount\fP Unmount callback, or NULL\&. .br \fIuser\fP Caller data passed to each callback\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "int bud_sprint_tree (const \fBbud_node\fP * root, char * buf, size_t bufsz)" .PP Render a compact ASCII tree dump for debugging\&. .PP \fBParameters\fP .RS 4 \fIroot\fP Root node\&. .br \fIbuf\fP Destination buffer\&. .br \fIbufsz\fP Capacity of buf\&. .RE .PP \fBReturns\fP .RS 4 Bytes written, or -1 when truncated\&. .RE .PP .SS "void bud_state_apply (void * state, const \fBbud_field_desc_t\fP * fields, const char * json)" .PP Apply JSON fields onto a state struct (fully flexible)\&. .PP \fBParameters\fP .RS 4 \fIstate\fP Destination struct\&. .br \fIfields\fP Field descriptor array, NULL-key terminated\&. .br \fIjson\fP NUL-terminated JSON\&. .RE .PP .SS "void bud_state_apply_array (const char * json, const char * key, void * array_out, size_t elem_size, int * count_out, int max_elems, const \fBbud_field_desc_t\fP * schema)" .PP Populate a fixed-capacity array from a JSON array field\&. .PP \fBParameters\fP .RS 4 \fIjson\fP NUL-terminated JSON\&. .br \fIkey\fP Field name holding the array\&. .br \fIarray_out\fP Destination array\&. .br \fIelem_size\fP Byte size of one element\&. .br \fIcount_out\fP In: capacity hint; out: filled count\&. .br \fImax_elems\fP Hard element cap\&. .br \fIschema\fP Per-field descriptors for each element\&. .RE .PP .SS "void bud_state_apply_array_len (const char * json, size_t len, const char * key, void * array_out, size_t elem_size, int * count_out, int max_elems, const \fBbud_field_desc_t\fP * schema)" .PP Populate a fixed-capacity array from a length-bounded JSON array\&. .PP \fBParameters\fP .RS 4 \fIjson\fP JSON bytes\&. .br \fIlen\fP Byte length of json\&. .br \fIkey\fP Field name holding the array\&. .br \fIarray_out\fP Destination array\&. .br \fIelem_size\fP Byte size of one element\&. .br \fIcount_out\fP In: capacity hint; out: filled count\&. .br \fImax_elems\fP Hard element cap\&. .br \fIschema\fP Per-field descriptors for each element\&. .RE .PP .SS "void bud_state_apply_array_stride_len (const char * json, size_t len, const char * key, void * array_out, size_t elem_size, int * count_out, int max_elems, const void * schema, size_t schema_stride)" .PP Populate a fixed-capacity array with caller-specified schema stride\&. .PP \fBParameters\fP .RS 4 \fIjson\fP JSON bytes\&. .br \fIlen\fP Byte length of json\&. .br \fIkey\fP Field name holding the array\&. .br \fIarray_out\fP Destination array\&. .br \fIelem_size\fP Byte size of one element\&. .br \fIcount_out\fP In: capacity hint; out: filled count\&. .br \fImax_elems\fP Hard element cap\&. .br \fIschema\fP Per-field descriptors for each element\&. .br \fIschema_stride\fP Stride between element descriptors\&. .RE .PP .SS "void bud_state_apply_len (void * state, const \fBbud_field_desc_t\fP * fields, const char * json, size_t len)" .PP Apply length-bounded JSON fields onto a state struct\&. .PP \fBParameters\fP .RS 4 \fIstate\fP Destination struct\&. .br \fIfields\fP Field descriptor array, NULL-key terminated\&. .br \fIjson\fP JSON bytes\&. .br \fIlen\fP Byte length of json\&. .RE .PP .SS "void bud_state_apply_stride (void * state, const void * fields, size_t field_stride, const char * json)" .PP Apply JSON onto a state struct with caller-specified field stride\&. .PP \fBParameters\fP .RS 4 \fIstate\fP Destination struct\&. .br \fIfields\fP Field descriptors\&. .br \fIfield_stride\fP Stride between descriptors\&. .br \fIjson\fP NUL-terminated JSON\&. .RE .PP .SS "void bud_state_apply_stride_len (void * state, const void * fields, size_t field_stride, const char * json, size_t len)" .PP Apply length-bounded JSON with caller-specified field stride\&. .PP \fBParameters\fP .RS 4 \fIstate\fP Destination struct\&. .br \fIfields\fP Field descriptors\&. .br \fIfield_stride\fP Stride between descriptors\&. .br \fIjson\fP JSON bytes\&. .br \fIlen\fP Byte length of json\&. .RE .PP .SS "\fBbud_node\fP * bud_submit_btn (const char * label, const char * class_name)" .PP Create a submit button element with an optional class\&. .PP \fBParameters\fP .RS 4 \fIlabel\fP Button label\&. .br \fIclass_name\fP CSS class, or NULL\&. .RE .PP \fBReturns\fP .RS 4 New button element node\&. .RE .PP .SS "\fBbud_node\fP * bud_text (const char * text)" .PP Create a text node (HTML-escaped on render)\&. .PP \fBParameters\fP .RS 4 \fItext\fP Text content\&. .RE .PP \fBReturns\fP .RS 4 New text node\&. .RE .PP .SS "\fBbud_node\fP * bud_text_lit (const char * text_lit)" .PP Create a text node with a static-lifetime string (zero-copy)\&. .PP \fBParameters\fP .RS 4 \fItext_lit\fP Static string literal text (not copied or freed)\&. .RE .PP \fBReturns\fP .RS 4 New text node\&. .RE .PP .SS "\fBbud_node\fP * bud_textf (const char * fmt, \&.\&.\&.)" .PP Create a text node from a printf-style format\&. .PP \fBParameters\fP .RS 4 \fIfmt\fP Format string\&. .RE .PP \fBReturns\fP .RS 4 New text node\&. .RE .PP .SS "int bud_toggle_class (\fBbud_node\fP * node, const char * cls)" .PP Toggle a CSS class on a node\&. .PP \fBParameters\fP .RS 4 \fInode\fP Target node\&. .br \fIcls\fP Class name\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "\fBbud_node\fP * bud_tpl (const char * fmt, \&.\&.\&.)" .PP Create a raw-HTML node from a printf-style format\&. .PP \fBParameters\fP .RS 4 \fIfmt\fP Format string\&. .RE .PP \fBReturns\fP .RS 4 New raw-HTML node\&. .RE .PP .SS "int bud_vdom_diff (\fBbud_node\fP * old_root, \fBbud_node\fP * new_root, \fBbud_emit_fn\fP emit, void * user)" .PP Diff two trees and emit minimal patch operations\&. .PP \fBParameters\fP .RS 4 \fIold_root\fP Previous tree\&. .br \fInew_root\fP New tree\&. .br \fIemit\fP Emission callback\&. .br \fIuser\fP Caller data passed to emit\&. .RE .PP \fBReturns\fP .RS 4 0 on success\&. .RE .PP .SS "\fBbud_node\fP * bud_vtpl (const char * fmt, va_list ap)" .PP Create a raw-HTML node from a format and va_list\&. .PP \fBParameters\fP .RS 4 \fIfmt\fP Format string\&. .br \fIap\fP Argument list\&. .RE .PP \fBReturns\fP .RS 4 New raw-HTML node\&. .RE .PP .SH "Author" .PP Generated automatically by Doxygen for bud from the source code\&.