#[non_exhaustive]pub struct ChangeBatch {
pub changes: Vec<Change>,
pub next: FeedPosition,
}Expand description
A batch of changes plus the cursor to resume from.
use kevy_embedded::{Config, Store};
let store = Store::open(Config::default().with_feed(0))?;
let from = store.changes_tail()?;
store.set(b"k", b"v")?;
let batch = store.changes_since(from, 10, &[])?;
assert_eq!(batch.changes.len(), 1);
assert_eq!(batch.next.offset, from.offset + 1);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.changes: Vec<Change>Delivered changes, offset order.
use kevy_embedded::{Config, Store};
let store = Store::open(Config::default().with_feed(0))?;
let from = store.changes_tail()?;
store.set(b"a", b"1")?;
store.del(&[b"a"])?;
let batch = store.changes_since(from, 10, &[])?;
let verbs: Vec<&[u8]> = batch.changes.iter().map(|c| &c.argv[0][..]).collect();
assert_eq!(verbs, [&b"SET"[..], b"DEL"]);next: FeedPositionThe cursor to pass to the next changes_since.
use kevy_embedded::{Config, Store};
let store = Store::open(Config::default().with_feed(0))?;
let from = store.changes_tail()?;
store.set(b"a", b"1")?;
store.set(b"b", b"2")?;
let first = store.changes_since(from, 1, &[])?;
// resuming at `next` picks up exactly where the first batch stopped
let rest = store.changes_since(first.next, 10, &[])?;
assert_eq!(rest.changes[0].argv[1], b"b");Implementations§
Source§impl ChangeBatch
impl ChangeBatch
Sourcepub fn new(changes: Vec<Change>, next: FeedPosition) -> Self
pub fn new(changes: Vec<Change>, next: FeedPosition) -> Self
A batch of changes resuming at next — the decoded form of a
server’s FEED.READ reply.
use kevy_embedded::{ChangeBatch, FeedPosition};
let caught_up = ChangeBatch::new(Vec::new(), FeedPosition::new(1, 42));
assert!(caught_up.changes.is_empty());
assert_eq!(caught_up.next.offset, 42);Trait Implementations§
Source§impl Clone for ChangeBatch
impl Clone for ChangeBatch
Source§impl Debug for ChangeBatch
impl Debug for ChangeBatch
impl Eq for ChangeBatch
Source§impl Hash for ChangeBatch
impl Hash for ChangeBatch
Source§impl PartialEq for ChangeBatch
impl PartialEq for ChangeBatch
impl StructuralPartialEq for ChangeBatch
Auto Trait Implementations§
impl Freeze for ChangeBatch
impl RefUnwindSafe for ChangeBatch
impl Send for ChangeBatch
impl Sync for ChangeBatch
impl Unpin for ChangeBatch
impl UnsafeUnpin for ChangeBatch
impl UnwindSafe for ChangeBatch
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