pub struct Cursor {
pub stream: StreamId,
pub seq: u64,
pub hash: Hash,
}Expand description
A reader’s place in a stream: which stream, how far, and what the history up to there was.
The position is the last entry the reader has; reading “after” the cursor returns the entries that follow it. The identity and the link make the cursor checkable: the relay answers a cursor only if the stream is the same incarnation and its chain has the same link at that position. Otherwise it says which of the two failed, and the reader knows its copy and the relay’s have parted - rather than reading on from a place that no longer exists.
The text form, used in URLs, is <position>.<stream>.<link>:
use efema_proto::{Cursor, StreamId};
let start = Cursor::start(StreamId::from_bytes([0xab; 16]));
let text = start.to_string();
assert!(text.starts_with("0.abababab"));
assert_eq!(text.parse::<Cursor>().unwrap(), start);Fields§
§stream: StreamIdThe stream incarnation this cursor belongs to.
seq: u64The position of the last entry the reader has; 0 before the first.
hash: HashThe chain link at seq.
Implementations§
Trait Implementations§
impl Copy for Cursor
impl Eq for Cursor
impl StructuralPartialEq for Cursor
Auto Trait Implementations§
impl Freeze for Cursor
impl RefUnwindSafe for Cursor
impl Send for Cursor
impl Sync for Cursor
impl Unpin for Cursor
impl UnsafeUnpin for Cursor
impl UnwindSafe for Cursor
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
Mutably borrows from an owned value. Read more