#[non_exhaustive]pub struct FeedPosition {
pub generation: u64,
pub offset: u64,
}Expand description
A point in a feed: an offset within one generation’s offset history.
The pair is the whole identity — an offset means nothing outside its
generation, so the two travel together: a feed cursor, the tail a
consumer resumes at, the position a replica claims at handshake, the
cursor a snapshot records. FeedPosition::default() is generation 0,
offset 0: the “no continuity claim” a fresh replica presents (no real
feed ever runs at generation 0).
use kevy_replicate::feed::FeedPosition;
let at = FeedPosition::new(7, 42);
assert_eq!((at.generation, at.offset), (7, 42));
assert_eq!(FeedPosition::default(), FeedPosition::new(0, 0));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.generation: u64The offset history this position belongs to: an opaque identity,
see fresh_generation. 0 = unknown.
use kevy_replicate::feed::FeedSource;
use kevy_replicate::source::ReplicationSource;
let feed = FeedSource::new(9, ReplicationSource::new(1 << 20));
assert_eq!(feed.tail().generation, 9);offset: u64The offset within that history.
use kevy_replicate::feed::FeedSource;
use kevy_replicate::source::ReplicationSource;
let mut feed = FeedSource::new(1, ReplicationSource::new(1 << 20));
let set = kevy_resp::Argv::from(vec![b"SET".to_vec(), b"k".to_vec(), b"v".to_vec()]);
feed.source_mut().push_mutation(&set);
assert_eq!(feed.tail().offset, 1); // the next write lands at offset 1Implementations§
Source§impl FeedPosition
impl FeedPosition
Sourcepub const fn new(generation: u64, offset: u64) -> FeedPosition
pub const fn new(generation: u64, offset: u64) -> FeedPosition
The position at offset in generation.
let at = kevy_replicate::feed::FeedPosition::new(3, 0);
assert_eq!(at.generation, 3);Trait Implementations§
Source§impl Clone for FeedPosition
impl Clone for FeedPosition
Source§fn clone(&self) -> FeedPosition
fn clone(&self) -> FeedPosition
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for FeedPosition
Source§impl Debug for FeedPosition
impl Debug for FeedPosition
Source§impl Default for FeedPosition
impl Default for FeedPosition
Source§fn default() -> FeedPosition
fn default() -> FeedPosition
Returns the “default value” for a type. Read more
impl Eq for FeedPosition
Source§impl Hash for FeedPosition
impl Hash for FeedPosition
Source§impl PartialEq for FeedPosition
impl PartialEq for FeedPosition
impl StructuralPartialEq for FeedPosition
Auto Trait Implementations§
impl Freeze for FeedPosition
impl RefUnwindSafe for FeedPosition
impl Send for FeedPosition
impl Sync for FeedPosition
impl Unpin for FeedPosition
impl UnsafeUnpin for FeedPosition
impl UnwindSafe for FeedPosition
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