pub enum FeedRead {
Resync {
tail: FeedPosition,
},
Future,
}Expand description
Why a feed read could not be served from the backlog.
use kevy_replicate::feed::{FeedPosition, FeedRead, FeedSource};
use kevy_replicate::source::ReplicationSource;
let feed = FeedSource::new(1, ReplicationSource::new(1 << 20));
match feed.read(FeedPosition::new(2, 0), 10) {
Err(FeedRead::Resync { tail }) => assert_eq!(tail, FeedPosition::new(1, 0)),
other => panic!("unexpected {other:?}"),
}Variants§
Resync
Cursor unservable (stale generation or evicted offset): rebuild from a scan, then resume from the carried tail cursor.
use kevy_replicate::feed::{FeedPosition, FeedRead, FeedSource};
use kevy_replicate::source::ReplicationSource;
// a 64-byte backlog keeps only the newest frame
let mut feed = FeedSource::new(1, ReplicationSource::new(64));
let set = kevy_resp::Argv::from(vec![b"SET".to_vec(), b"k".to_vec(), b"v".to_vec()]);
for _ in 0..3 {
feed.source_mut().push_mutation(&set);
}
let err = feed.read(FeedPosition::new(1, 0), 10).unwrap_err();
assert_eq!(err, FeedRead::Resync { tail: FeedPosition::new(1, 3) });Fields
§
tail: FeedPositionThe current generation and the next offset the source will assign: where to resume.
use kevy_replicate::feed::{FeedPosition, FeedRead, FeedSource};
use kevy_replicate::source::ReplicationSource;
let feed = FeedSource::new(4, ReplicationSource::new(1 << 20));
let Err(FeedRead::Resync { tail }) = feed.read(FeedPosition::new(3, 0), 10) else { panic!() };
assert!(feed.read(tail, 10)?.is_empty()); // resuming at the tail is servedFuture
Cursor is ahead of the stream (offset > next) in the CURRENT
generation — caller bug or epoch confusion; reject the read.
(A mismatched generation is Resync, never Future:
generations carry no order to be “ahead” in.)
use kevy_replicate::feed::{FeedPosition, FeedRead, FeedSource};
use kevy_replicate::source::ReplicationSource;
let feed = FeedSource::new(1, ReplicationSource::new(1 << 20));
assert_eq!(feed.read(FeedPosition::new(1, 5), 10), Err(FeedRead::Future));Trait Implementations§
impl Copy for FeedRead
impl Eq for FeedRead
impl StructuralPartialEq for FeedRead
Auto Trait Implementations§
impl Freeze for FeedRead
impl RefUnwindSafe for FeedRead
impl Send for FeedRead
impl Sync for FeedRead
impl Unpin for FeedRead
impl UnsafeUnpin for FeedRead
impl UnwindSafe for FeedRead
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