pub struct StreamCursor {
pub block_number: u64,
pub log_index: u32,
pub version: u64,
}Expand description
An opaque cursor representing a position in the event stream.
Cursors are comparable and serializable, allowing consumers to persist
their position and resume after restarts. The version field is bumped
on reorgs to invalidate stale cursors.
Fields§
§block_number: u64The block number of the last consumed event.
log_index: u32The log index of the last consumed event within its block.
version: u64Stream version — incremented on reorg to invalidate old cursors.
Implementations§
Source§impl StreamCursor
impl StreamCursor
Sourcepub fn initial() -> Self
pub fn initial() -> Self
Create an initial cursor at the beginning of the stream.
This cursor represents “no events consumed yet” and will return
all available events on the first next_batch call.
Sourcepub fn encode(&self) -> String
pub fn encode(&self) -> String
Serialize this cursor to a JSON string for persistence.
The encoded form can be stored in a database or sent over the wire,
then decoded back with StreamCursor::decode.
Sourcepub fn decode(encoded: &str) -> Result<Self, IndexerError>
pub fn decode(encoded: &str) -> Result<Self, IndexerError>
Deserialize a cursor from its encoded JSON string.
Returns an error if the string is not a valid cursor encoding.
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