pub enum StreamCursor {
Start,
End,
At(String),
}Expand description
Opaque cursor for read_stream / tail_stream — re-export of
ff_core::contracts::StreamCursor. Wire tokens: "start", "end",
"<ms>", "<ms>-<seq>". Bare - / + are rejected — use
StreamCursor::Start / StreamCursor::End instead.
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() -> StreamCursor
pub fn from_beginning() -> StreamCursor
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() -> StreamCursor
pub fn start() -> StreamCursor
Serde default helper — emits StreamCursor::Start. Used as
#[serde(default = "StreamCursor::start")] on REST query
structs.
Sourcepub fn end() -> StreamCursor
pub fn end() -> StreamCursor
Serde default helper — emits StreamCursor::End.
Sourcepub fn beginning() -> StreamCursor
pub fn beginning() -> StreamCursor
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 moreSource§impl Debug for StreamCursor
impl Debug for StreamCursor
Source§impl<'de> Deserialize<'de> for StreamCursor
impl<'de> Deserialize<'de> for StreamCursor
Source§fn deserialize<D>(
deserializer: D,
) -> Result<StreamCursor, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<StreamCursor, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for StreamCursor
impl Display for StreamCursor
Source§impl FromStr for StreamCursor
impl FromStr for StreamCursor
Source§type Err = StreamCursorParseError
type Err = StreamCursorParseError
Source§fn from_str(s: &str) -> Result<StreamCursor, <StreamCursor as FromStr>::Err>
fn from_str(s: &str) -> Result<StreamCursor, <StreamCursor as FromStr>::Err>
s to return a value of this type. Read moreSource§impl Hash for StreamCursor
impl Hash for StreamCursor
Source§impl PartialEq for StreamCursor
impl PartialEq for StreamCursor
Source§impl Serialize for StreamCursor
impl Serialize for StreamCursor
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§impl TryFrom<String> for StreamCursor
impl TryFrom<String> for StreamCursor
Source§type Error = StreamCursorParseError
type Error = StreamCursorParseError
Source§fn try_from(
s: String,
) -> Result<StreamCursor, <StreamCursor as TryFrom<String>>::Error>
fn try_from( s: String, ) -> Result<StreamCursor, <StreamCursor as TryFrom<String>>::Error>
impl Eq for StreamCursor
impl StructuralPartialEq for StreamCursor
Auto Trait Implementations§
impl Freeze for StreamCursor
impl RefUnwindSafe for StreamCursor
impl Send for StreamCursor
impl Sync for StreamCursor
impl Unpin for StreamCursor
impl UnsafeUnpin for StreamCursor
impl UnwindSafe for StreamCursor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.