Skip to main content

SlotDelta

Struct SlotDelta 

Source
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

Source

pub fn new() -> Self

Starts with no remembered previous call, so the first Self::digest call hashes every slot in current as changed.

Source

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.

Trait Implementations§

Source§

impl Default for SlotDelta

Source§

fn default() -> SlotDelta

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

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> 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, 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.