Skip to main content

SnapshotMarker

Enum SnapshotMarker 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Trait Implementations§

Source§

impl Clone for SnapshotMarker

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SnapshotMarker

Source§

impl Debug for SnapshotMarker

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SnapshotMarker

Source§

impl Hash for SnapshotMarker

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for SnapshotMarker

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SnapshotMarker

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.