Skip to main content

StreamingDiffer

Trait StreamingDiffer 

Source
pub trait StreamingDiffer<S: Store> {
    // Required method
    fn stream_diff<'a>(
        &'a self,
        store: &'a S,
        base: &Tree,
        other: &Tree,
    ) -> Result<Box<dyn Iterator<Item = Result<Diff, Error>> + 'a>, Error>;
}
Expand description

Trait for streaming diff operations.

Implementations yield differences lazily without collecting all results upfront. This is memory-efficient for large trees and supports early termination.

§Type Parameters

  • S - The storage backend type implementing Store

§Example

use prolly::{Prolly, MemStore, Config};
use std::sync::Arc;

let store = Arc::new(MemStore::new());
let prolly = Prolly::new(store.clone(), Config::default());

let base = prolly.create();
let other = prolly.put(&base, b"a".to_vec(), b"1".to_vec()).unwrap();

// Use the streaming diff
let diffs: Vec<_> = prolly.stream_diff(&base, &other)
    .unwrap()
    .filter_map(|r| r.ok())
    .collect();

Required Methods§

Source

fn stream_diff<'a>( &'a self, store: &'a S, base: &Tree, other: &Tree, ) -> Result<Box<dyn Iterator<Item = Result<Diff, Error>> + 'a>, Error>

Create a streaming diff iterator between two trees.

§Arguments
  • store - The storage backend
  • base - The base tree to compare from
  • other - The other tree to compare to
§Returns

An iterator yielding Result<Diff, Error> entries in lexicographic key order.

§Short-circuit

If both trees have the same root CID, returns an empty iterator immediately.

§Errors

Returns an error if cursor initialization fails.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§