pub enum StreamCursor {
Start,
End,
At(String),
}Expand description
Opaque cursor for attempt-stream reads/tails.
Replaces the bare &str / String stream-id parameters previously
carried on read_stream / tail_stream / ReadStreamParams /
TailStreamParams. The wire form is a flat string — serde is
transparent via try_from/into — so ?from=start&to=end and
?after=123-0 continue to work for REST clients.
§Public wire grammar
The ONLY accepted tokens are:
"start"— first entry in the stream (XRANGE-equivalent). Valid inread_stream/ReadStreamParams."end"— latest entry in the stream (XRANGE+equivalent). Valid inread_stream/ReadStreamParams."<ms>"or"<ms>-<seq>"— a concrete Valkey Stream entry id. Valid everywhere.
The bare XRANGE/XREAD markers "-" and "+" are NOT accepted
on the wire. The opaque StreamCursor grammar is the public
contract; the Valkey -/+ markers are an internal implementation
detail carried only inside the Lua-adjacent ReadFramesArgs /
xread_block path via StreamCursor::to_wire.
For XREAD (tail), the documented “from the beginning” convention is
StreamCursor::At("0-0".into()) — use the convenience constructor
StreamCursor::from_beginning which returns exactly that value.
Start / End are rejected by the SDK’s tail_stream boundary
because XREAD does not accept - / + as cursors. The
StreamCursor::is_concrete helper centralises this
Start/End-vs-At decision for boundary-validation call sites.
§Why an enum instead of a string
A string parameter lets malformed ids escape to the Lua/Valkey
layer, surfacing as a script error and HTTP 500. An enum with
fallible FromStr / TryFrom<String> catches every malformed input
at the wire boundary with a structured error, and prevents bare -
/ + from leaking into consumer code as tacit extensions of the
public API.
Variants§
Start
First entry in the stream (XRANGE start marker).
End
Latest entry in the stream (XRANGE end marker).
At(String)
A concrete Valkey Stream entry id (<ms> or <ms>-<seq>).
For XREAD-style tails, the documented “from the beginning”
convention is At("0-0".to_owned()) — see
StreamCursor::from_beginning.
Implementations§
Source§impl StreamCursor
impl StreamCursor
Sourcepub fn from_beginning() -> Self
pub fn from_beginning() -> Self
Convenience constructor for the XREAD-from-beginning convention
("0-0"). XREAD’s last_id is exclusive, so passing this as
the after cursor returns every entry in the stream.
Sourcepub fn start() -> Self
pub fn start() -> Self
Serde default helper — emits StreamCursor::Start. Used as
#[serde(default = "StreamCursor::start")] on REST query
structs.
Sourcepub fn beginning() -> Self
pub fn beginning() -> Self
Serde default helper — emits
StreamCursor::from_beginning(). Used as the default for
TailStreamParams::after.
Sourcepub fn is_concrete(&self) -> bool
pub fn is_concrete(&self) -> bool
True iff this cursor is a concrete entry id
("<ms>" / "<ms>-<seq>"). False for the open markers
Start / End.
Used by boundaries like XREAD (tailing) that do not accept
open markers — rejecting a cursor is equivalent to
!cursor.is_concrete(). Centralised here to keep the SDK and
REST guards in lock-step.
Trait Implementations§
Source§impl Clone for StreamCursor
impl Clone for StreamCursor
Source§fn clone(&self) -> StreamCursor
fn clone(&self) -> StreamCursor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more