pub struct SlotDelta { /* private fields */ }Expand description
Per-slot “changed since last call” bookkeeping for a framebuffer-shaped Observable.
A framebuffer-shaped backend (a Grid, a layer list, anything replaced rather than appended
to) can’t hash its slice-since-last-time the way an append-log backend can, because there is
no new slice: the whole buffer is rewritten in place. SlotDelta remembers the previous call’s
per-slot digests and XORs in only the ones that changed, plus a slot-count term so a
shrink-then-grow back to the same per-slot content doesn’t hash identically to no change at
all (that term is also what a plain zip of previous/current would silently drop on a resize).
Implementations§
Source§impl SlotDelta
impl SlotDelta
Sourcepub fn new() -> Self
pub fn new() -> Self
Starts with no remembered previous call, so the first Self::digest call hashes every
slot in current as changed.
Sourcepub fn digest(
&mut self,
salt: &[u8],
current: impl IntoIterator<Item = u64>,
) -> u64
pub fn digest( &mut self, salt: &[u8], current: impl IntoIterator<Item = u64>, ) -> u64
Hashes the slots of current that differ from the previous call’s, salted with salt so
callers sharing one fnv1a namespace don’t collide, and remembers current for next
time.
XOR composition is order-independent for unique slot indices, so it does not matter that the per-slot terms below are accumulated in iteration order.