pub enum FromOffset {
TooOld,
Future,
}Expand description
Reason ReplicationSource::frames_from cannot serve a replica
from the backlog.
use kevy_replicate::source::{FromOffset, ReplicationSource};
let backlog = ReplicationSource::new(1 << 20);
let action = match backlog.frames_from(7) {
Err(FromOffset::TooOld) => "ship a snapshot",
Err(FromOffset::Future) => "drop the link", // the replica is ahead of us
Ok(_frames) => "stream the frames",
};
assert_eq!(action, "drop the link");Variants§
TooOld
The replica is asking for an offset we already evicted; the streaming loop must initiate a snapshot ship.
use kevy_replicate::source::{FromOffset, ReplicationSource};
let set = kevy_resp::Argv::from(vec![b"SET".to_vec(), b"k".to_vec(), b"v".to_vec()]);
let mut backlog = ReplicationSource::new(1 << 20);
backlog.push_mutation(&set);
backlog.push_mutation(&set);
backlog.drop_up_to(1); // offset 0 is gone
assert!(matches!(backlog.frames_from(0), Err(FromOffset::TooOld)));Future
The replica’s requested offset is greater than the next offset we would assign — peer is ahead of us (data-dir wipe, epoch confusion, or bug). The caller should drop the link.
use kevy_replicate::source::{FromOffset, ReplicationSource};
let backlog = ReplicationSource::new(1 << 20); // assigns offset 0 next
assert!(matches!(backlog.frames_from(1), Err(FromOffset::Future)));Trait Implementations§
Source§impl Clone for FromOffset
impl Clone for FromOffset
impl Copy for FromOffset
Source§impl Debug for FromOffset
impl Debug for FromOffset
impl Eq for FromOffset
Source§impl Hash for FromOffset
impl Hash for FromOffset
Source§impl PartialEq for FromOffset
impl PartialEq for FromOffset
impl StructuralPartialEq for FromOffset
Auto Trait Implementations§
impl Freeze for FromOffset
impl RefUnwindSafe for FromOffset
impl Send for FromOffset
impl Sync for FromOffset
impl Unpin for FromOffset
impl UnsafeUnpin for FromOffset
impl UnwindSafe for FromOffset
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