Skip to main content

Change

Struct Change 

Source
#[non_exhaustive]
pub struct Change { pub offset: u64, pub argv: Vec<Vec<u8>>, }
Expand description

One mutation delivered by Store::changes_since.

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, &[])?;
let change = &batch.changes[0];
assert_eq!(change.offset, from.offset);
assert_eq!(change.argv[0], b"SET");

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.
§offset: u64

Stream offset (monotonic within a generation).

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 offsets: Vec<u64> = store.changes_since(from, 10, &[])?.changes.iter().map(|c| c.offset).collect();
assert_eq!(offsets, [from.offset, from.offset + 1]);
§argv: Vec<Vec<u8>>

The applied effect’s argv (same frames the AOF / a replica sees).

use kevy_embedded::{Config, Store};

let store = Store::open(Config::default().with_feed(0))?;
let from = store.changes_tail()?;
store.hset(b"h", &[(b"f", b"v")])?;
let argv = &store.changes_since(from, 10, &[])?.changes[0].argv;
assert_eq!(argv, &[b"HSET".to_vec(), b"h".to_vec(), b"f".to_vec(), b"v".to_vec()]);

Implementations§

Source§

impl Change

Source

pub fn new(offset: u64, argv: Vec<Vec<u8>>) -> Self

A change at offset carrying argv — what a client decoding a server’s FEED.READ reply builds, so both backends hand back the same type.

let c = kevy_embedded::Change::new(7, vec![b"DEL".to_vec(), b"k".to_vec()]);
assert_eq!((c.offset, c.argv.len()), (7, 2));

Trait Implementations§

Source§

impl Clone for Change

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 Debug for Change

Source§

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

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

impl Eq for Change

Source§

impl Hash for Change

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 Change

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 Change

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.