Skip to main content

Module stream_subscribe

Module stream_subscribe 

Source
Expand description

RFC-019 Stage A/B/C — cross-backend stream-cursor subscription surface (shared primitives).

This module defines the StreamCursor every subscribe_* method accepts, plus the codec helpers backends use to encode/decode their native stream positions (Valkey (ms, seq), Postgres event_id). Family-specific typed event enums + per- family subscription aliases live in crate::stream_events.

Four-family allow-list (RFC-019 §Open Questions #5, owner- adjudicated 2026-04-24): new families require an RFC amendment.

Structs§

StreamCursor
Opaque, backend-versioned cursor. Consumers persist the bytes, hand them back on resume. The first byte MUST encode a backend-family + version prefix so cursors stay stable across backend upgrades (Valkey: 0x01, Postgres: 0x02, …). The remainder is backend- specific.

Constants§

POSTGRES_CURSOR_PREFIX
Postgres family prefix byte.
VALKEY_CURSOR_PREFIX
Valkey family prefix byte (RFC-019 §Backend Semantics Appendix).

Functions§

decode_postgres_event_cursor
Decode a Postgres event cursor back to event_id. None = start-from-tail.
decode_valkey_cursor
Decode a Valkey cursor back to (ms, seq). Returns None for the empty / tail-from-now cursor. Returns Err for malformed bytes (wrong prefix, truncated).
encode_postgres_event_cursor
Encode a Postgres event_id (i64, from ff_completion_event) into a cursor.
encode_valkey_cursor
Encode a Valkey stream id (ms, seq) into a cursor.