#[non_exhaustive]pub enum SnapshotMarker {
Begin,
End(u64),
Ping(FeedPosition),
}Expand description
Decoded snapshot marker, returned by decode_snapshot_marker.
use kevy_replicate::wire::{SnapshotMarker, decode_snapshot_marker, encode_snapshot_end};
let (marker, _) = decode_snapshot_marker(&encode_snapshot_end(12))?.expect("a marker line");
let next_live_offset = match marker {
SnapshotMarker::End(ack) => ack,
other => panic!("unexpected {other:?}"),
};
assert_eq!(next_live_offset, 12);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Begin
+SNAPSHOT\r\n — primary is about to stream snapshot chunks.
use kevy_replicate::wire::{SnapshotMarker, decode_snapshot_marker};
assert_eq!(decode_snapshot_marker(b"+SNAPSHOT\r\n")?, Some((SnapshotMarker::Begin, 11)));End(u64)
+SNAPSHOT_END <ack_offset>\r\n — end of snapshot; the next
live frame’s offset will equal ack_offset.
use kevy_replicate::wire::{SnapshotMarker, decode_snapshot_marker};
let line = b"+SNAPSHOT_END 42\r\n";
assert_eq!(decode_snapshot_marker(line)?, Some((SnapshotMarker::End(42), line.len())));Ping(FeedPosition)
+PING <generation> <next_offset>\r\n — in-stream
heartbeat: the primary’s current feed generation + next_offset,
sent every ~1s so a replica can compute its own lag (applied vs
primary) and judge link liveness without a request/response
round trip. Out-of-band: occupies no offset space.
The generation lets REPL.TOKEN / REPL.WAIT compare
token generations against the replica’s last-seen upstream
generation. A legacy one-number +PING <next_offset>\r\n line
still decodes — generation reads as 0, the “unknown” value
no real feed ever serves (feed generations start at 1).
use kevy_replicate::feed::FeedPosition;
use kevy_replicate::wire::{SnapshotMarker, decode_snapshot_marker};
let (ping, _) = decode_snapshot_marker(b"+PING 3 120\r\n")?.expect("a marker line");
assert_eq!(ping, SnapshotMarker::Ping(FeedPosition::new(3, 120)));
let (legacy, _) = decode_snapshot_marker(b"+PING 120\r\n")?.expect("a marker line");
assert_eq!(legacy, SnapshotMarker::Ping(FeedPosition::new(0, 120))); // generation unknown