code wiki / (root) / nx_chat_ring.nx

nx_chat_ring.nx

buildroot/runtime/nx_chat_ring.nx

6467 B190 linesdepth 3pulls 3 transitivereach 3 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_chat_ring.nx -- bounded-ring chat buffer with sealed message slots. Promoted from the nishi_video_room_synology.nx L77-L78 chat ring (per [[project-nishifamily-video-l66-l75-2026-05-16]] commits 8406e7a9 + 846fd399). Same wire format + same persistence semantics; new home is the OOP layer so any consumer (video room, nx_call, nx_cli_meet, nx_iot_intercom) can reuse it without re-implementing. Ring contract: - Sealed capacity at construction; full ring wraps oldest-first. - Monotonic sequence numbers (consumers can ask "what's new since N?"). - Per-message metadata: seq, sender_peer_id, kind, byte_len, unix_ms. - Pluggable persistence (disk / memory / future MLS-encrypted).

dependencies 1 imports · 3 importers

nx_syscalls_x86_64.nx nx_chat_ring.nx nx_call.nx nx_chat_session.nx nx_cli_meet.nx

imports: nx_syscalls_x86_64.nx

imported by: nx_call.nxnx_chat_session.nxnx_cli_meet.nx

structs

51struct ChatSlot
64struct nx_chat_ring

consts

28const NX_CHAT_KIND_UNKNOWN: i64 = 0
29const NX_CHAT_KIND_TEXT: i64 = 1 // plain user text
30const NX_CHAT_KIND_REACT: i64 = 2 // emoji/reaction
31const NX_CHAT_KIND_PRESENCE: i64 = 3 // "alice joined / alice left"
32const NX_CHAT_KIND_SYS: i64 = 4 // server status notice
33const NX_CHAT_KIND_NAME: i64 = 5 // peer set display name
34const NX_CHAT_KIND_HANDRAISE: i64 = 6
35const NX_CHAT_KIND_N: i64 = 7
39const NX_CHAT_RING_OK: i64 = 0
40const NX_CHAT_RING_ERR_FULL_TXT: i64 = -1 // body too big for ring text-arena
41const NX_CHAT_RING_ERR_BAD_KIND: i64 = -2
42const NX_CHAT_RING_ERR_BAD_SEQ: i64 = -3
43const NX_CHAT_RING_ERR_TXT_CAP: i64 = -4 // requested single msg larger than ring text capacity
60const NX_CHAT_SLOT_BYTES: i64 = 48
75const NX_CHAT_RING_BYTES: i64 = 64

functions

79func nx_chat_ring_new(r: *nx_chat_ring, cap_slots: i64, txt_cap: i64) -> i64
called by 1: nx_chat_session_new
103func nx_chat_ring_append(r: *nx_chat_ring,
144func nx_chat_ring_next_seq(r: *nx_chat_ring) -> i64
148func nx_chat_ring_count(r: *nx_chat_ring) -> i64
155func nx_chat_ring_get_by_seq(r: *nx_chat_ring, seq: i64) -> *ChatSlot
167func nx_chat_ring_get_at(r: *nx_chat_ring, i: i64) -> *ChatSlot
180func nx_chat_ring_copy_text(r: *nx_chat_ring, slot: *ChatSlot,