pub struct Batch<A: Adapter> { /* private fields */ }Expand description
A batch collector for aggregating and optimizing multiple mutations.
Batch is used internally to collect multiple mutations and optimize them before creating the
final mutation. It can merge consecutive append operations and eliminate redundant mutations.
§Type Parameters
A- The adapter type used for serialization
§Example
use morphix::{Batch, JsonAdapter, Mutation, MutationKind};
use serde_json::json;
let mut batch = Batch::<JsonAdapter>::new();
// Load multiple mutations
batch.load(Mutation {
path_rev: vec!["field".into()],
operation: MutationKind::Replace(json!(1)),
}).unwrap();
// Dump optimized mutations
let optimized = batch.dump();Implementations§
Source§impl<A: Adapter> Batch<A>
impl<A: Adapter> Batch<A>
Sourcepub fn load(&mut self, mutation: Mutation<A>) -> Result<(), MutationError>
pub fn load(&mut self, mutation: Mutation<A>) -> Result<(), MutationError>
Loads a Mutation into the batch, potentially merging with existing mutations.
§Arguments
mutation- mutation to add to the batch
§Errors
- Returns an MutationError if the mutation cannot be applied.
Trait Implementations§
Auto Trait Implementations§
impl<A> Freeze for Batch<A>
impl<A> RefUnwindSafe for Batch<A>
impl<A> Send for Batch<A>
impl<A> Sync for Batch<A>
impl<A> Unpin for Batch<A>
impl<A> UnwindSafe for Batch<A>
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