Skip to main content

with_protection

Function with_protection 

Source
pub fn with_protection<R>(
    tx: &mut Transaction<'_>,
    vertices: &[VertexId],
    weights: &[f32],
    op: impl FnOnce(&mut Transaction<'_>) -> Result<R>,
) -> Result<R>
Expand description

Runs op in tx, then scales each listed vertex’s move by its weight: 0 leaves the vertex at the bits it had before op, 1 keeps the whole move, and values in between land on the straight line between the two.

Vertices that end where they started are not written. op must leave the listed vertices alive. What op reports describes its own move, before the scaling: a neighbor it computed against a protected vertex’s moved position keeps that result.

§Errors

  • OpsError::InvalidInput when the lists differ in length, a weight is not in [0, 1], or a listed vertex is not alive; op has not run then.
  • Whatever op returns, and OpsError::Store when memory runs out. The caller’s transaction should then be rolled back.