Skip to main content

DiffSet

Struct DiffSet 

Source
pub struct DiffSet<F: Format<S, B>, T: SchemaWithPK, S, B> { /* private fields */ }
Expand description

A frozen changeset or patchset whose rows are emitted in stored order.

DiffSet is produced by the binary parser (via ParsedDiffSet) or by converting from a DiffSetBuilder using Into::into. Unlike DiffSetBuilder, it stores tables and rows in a plain Vec, reflecting the fact that no further mutation or PK-based lookup is needed.

build serializes rows in the order they are stored. No session hash-table simulation is applied. This preserves the original row order of parsed binary data across roundtrips.

To modify a DiffSet, convert it back to a DiffSetBuilder using Into::into.

Implementations§

Source§

impl<F: Format<S, B>, T: SchemaWithPK, S: AsRef<str> + Hash + Eq, B: AsRef<[u8]> + Hash + Eq> DiffSet<F, T, S, B>

Source

pub fn is_empty(&self) -> bool

Returns true if there are no operations in any table.

Source

pub fn len(&self) -> usize

Returns the total number of operations across all tables.

Source§

impl<F: Format<S, B>, T: SchemaWithPK, S: AsRef<str> + Hash + Eq, B: AsRef<[u8]> + Hash + Eq> DiffSet<F, T, S, B>

Source

pub fn tables(&self) -> impl Iterator<Item = &T>

Returns the schema of each table that holds at least one operation, in stored order.

Source§

impl<T: SchemaWithPK, S: Clone + Debug + AsRef<str>, B: Clone + Debug + AsRef<[u8]>> DiffSet<ChangesetFormat, T, S, B>

Source

pub fn iter(&self) -> impl Iterator<Item = ChangesetOp<'_, T, S, B>>

Iterate over every operation in the changeset.

Operations are yielded in stored order, grouped by table. Each ChangesetOp borrows from this DiffSet, so the returned iterator is invalidated when the DiffSet is dropped or mutated.

Source§

impl<T: SchemaWithPK, S: Clone + AsRef<str>, B: Clone + AsRef<[u8]>> DiffSet<PatchsetFormat, T, S, B>

Source

pub fn iter(&self) -> impl Iterator<Item = PatchsetOp<'_, T, S, B>>

Iterate over every operation in the patchset.

Operations are yielded in stored order, grouped by table. Each PatchsetOp borrows from this DiffSet. For DELETE and UPDATE ops only the primary-key columns are available (patchset format does not carry full old-row values).

Source§

impl<T: SchemaWithPK, S: Clone + Debug + Hash + Eq + AsRef<str>, B: Clone + Debug + Hash + Eq + AsRef<[u8]>> DiffSet<ChangesetFormat, T, S, B>

Source

pub fn build(&self) -> Vec<u8>

Serialize the changeset to binary.

Rows are emitted in stored order (no hash simulation).

Source§

impl<T: SchemaWithPK, S: Clone + Hash + Eq + AsRef<str>, B: Clone + Hash + Eq + AsRef<[u8]>> DiffSet<PatchsetFormat, T, S, B>

Source

pub fn build(&self) -> Vec<u8>

Serialize the patchset to binary.

Rows are emitted in stored order (no hash simulation).

Trait Implementations§

Source§

impl<F: Clone + Format<S, B>, T: Clone + SchemaWithPK, S: Clone, B: Clone> Clone for DiffSet<F, T, S, B>

Source§

fn clone(&self) -> DiffSet<F, T, S, B>

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<F: Debug + Format<S, B>, T: Debug + SchemaWithPK, S: Debug, B: Debug> Debug for DiffSet<F, T, S, B>

Source§

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

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

impl<F: Format<S, B>, T: SchemaWithPK, S: AsRef<str> + Hash + Eq, B: AsRef<[u8]> + Hash + Eq> Default for DiffSet<F, T, S, B>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: SchemaWithPK, S: Clone + Debug + Hash + Eq + AsRef<str>, B: Clone + Debug + Hash + Eq + AsRef<[u8]>> DiffOps<T, S, B> for DiffSet<ChangesetFormat, T, S, B>

Source§

type Format = ChangesetFormat

The format (changeset or patchset) of the diff set.
Source§

type DeleteArg = ChangeDelete<T, S, B>

The argument type for the delete operation. Read more
Source§

fn insert( self, insert: Insert<T, S, B>, ) -> DiffSetBuilder<ChangesetFormat, T, S, B>

Add an INSERT operation.
Source§

fn delete( self, delete: ChangeDelete<T, S, B>, ) -> DiffSetBuilder<ChangesetFormat, T, S, B>

Add a DELETE operation.
Source§

fn update( self, update: Update<T, ChangesetFormat, S, B>, ) -> DiffSetBuilder<ChangesetFormat, T, S, B>

Add an UPDATE operation.
Source§

impl<T: SchemaWithPK, S: Clone + Hash + Eq + AsRef<str>, B: Clone + Hash + Eq + AsRef<[u8]>> DiffOps<T, S, B> for DiffSet<PatchsetFormat, T, S, B>

Source§

type Format = PatchsetFormat

The format (changeset or patchset) of the diff set.
Source§

type DeleteArg = PatchDelete<T, S, B>

The argument type for the delete operation. Read more
Source§

fn insert( self, insert: Insert<T, S, B>, ) -> DiffSetBuilder<PatchsetFormat, T, S, B>

Add an INSERT operation.
Source§

fn delete( self, delete: PatchDelete<T, S, B>, ) -> DiffSetBuilder<PatchsetFormat, T, S, B>

Add a DELETE operation.
Source§

fn update( self, update: Update<T, PatchsetFormat, S, B>, ) -> DiffSetBuilder<PatchsetFormat, T, S, B>

Add an UPDATE operation.
Source§

impl<F: Format<S, B>, T: SchemaWithPK, S, B> Eq for DiffSet<F, T, S, B>
where S: Eq + Hash + AsRef<str>, B: Eq + Hash + AsRef<[u8]>, F::Old: Eq, F::DeleteData: Eq,

Source§

impl<T: SchemaWithPK, S: Clone + Debug + Hash + Eq + AsRef<str>, B: Clone + Debug + Hash + Eq + AsRef<[u8]>> From<&DiffSet<ChangesetFormat, T, S, B>> for Vec<u8>

Source§

fn from(diffset: &DiffSet<ChangesetFormat, T, S, B>) -> Self

Converts to this type from the input type.
Source§

impl<T: SchemaWithPK, S: AsRef<str> + Clone + Hash + Eq, B: AsRef<[u8]> + Clone + Hash + Eq> From<&DiffSet<PatchsetFormat, T, S, B>> for Vec<u8>

Source§

fn from(diffset: &DiffSet<PatchsetFormat, T, S, B>) -> Self

Converts to this type from the input type.
Source§

impl<T: SchemaWithPK, S: Clone + Debug + Hash + Eq + AsRef<str>, B: Clone + Debug + Hash + Eq + AsRef<[u8]>> From<DiffSet<ChangesetFormat, T, S, B>> for Vec<u8>

Source§

fn from(diffset: DiffSet<ChangesetFormat, T, S, B>) -> Self

Converts to this type from the input type.
Source§

impl<F: Format<S, B>, T: SchemaWithPK, S: Hash + Eq + AsRef<str>, B: Hash + Eq + AsRef<[u8]>> From<DiffSet<F, T, S, B>> for DiffSetBuilder<F, T, S, B>

Source§

fn from(diffset: DiffSet<F, T, S, B>) -> Self

Converts to this type from the input type.
Source§

impl<T: SchemaWithPK, S: AsRef<str> + Clone + Hash + Eq, B: AsRef<[u8]> + Clone + Hash + Eq> From<DiffSet<PatchsetFormat, T, S, B>> for Vec<u8>

Source§

fn from(diffset: DiffSet<PatchsetFormat, T, S, B>) -> Self

Converts to this type from the input type.
Source§

impl<F: Format<S, B>, T: SchemaWithPK, S: Hash + Eq + AsRef<str>, B: Hash + Eq + AsRef<[u8]>> From<DiffSetBuilder<F, T, S, B>> for DiffSet<F, T, S, B>

Source§

fn from(builder: DiffSetBuilder<F, T, S, B>) -> Self

Converts to this type from the input type.
Source§

impl<F: Format<S, B>, T: SchemaWithPK, S, B> PartialEq for DiffSet<F, T, S, B>
where S: PartialEq + Eq + Hash + AsRef<str>, B: PartialEq + Eq + Hash + AsRef<[u8]>, F::Old: PartialEq, F::DeleteData: PartialEq,

Custom PartialEq that ignores tables with no operations (same semantics as DiffSetBuilder).

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: SchemaWithPK, S: Clone + Debug + Hash + Eq + AsRef<str>, B: Clone + Debug + Hash + Eq + AsRef<[u8]>> Reverse for DiffSet<ChangesetFormat, T, S, B>

Source§

type Output = DiffSet<ChangesetFormat, T, S, B>

The reverse of this operation.
Source§

fn reverse(self) -> Self::Output

Returns the reverse of this operation.

Auto Trait Implementations§

§

impl<F, T, S, B> Freeze for DiffSet<F, T, S, B>

§

impl<F, T, S, B> RefUnwindSafe for DiffSet<F, T, S, B>
where T: RefUnwindSafe, <F as Format<S, B>>::DeleteData: RefUnwindSafe, S: RefUnwindSafe, B: RefUnwindSafe, <F as Format<S, B>>::Old: RefUnwindSafe,

§

impl<F, T, S, B> Send for DiffSet<F, T, S, B>
where T: Send, <F as Format<S, B>>::DeleteData: Send, S: Send, B: Send, <F as Format<S, B>>::Old: Send,

§

impl<F, T, S, B> Sync for DiffSet<F, T, S, B>
where T: Sync, <F as Format<S, B>>::DeleteData: Sync, S: Sync, B: Sync, <F as Format<S, B>>::Old: Sync,

§

impl<F, T, S, B> Unpin for DiffSet<F, T, S, B>
where T: Unpin, <F as Format<S, B>>::DeleteData: Unpin, S: Unpin, B: Unpin, <F as Format<S, B>>::Old: Unpin,

§

impl<F, T, S, B> UnsafeUnpin for DiffSet<F, T, S, B>

§

impl<F, T, S, B> UnwindSafe for DiffSet<F, T, S, B>
where T: UnwindSafe, <F as Format<S, B>>::DeleteData: UnwindSafe, S: UnwindSafe, B: UnwindSafe, <F as Format<S, B>>::Old: UnwindSafe,

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.