pub struct ClosedRouter {
pub(crate) inner: RouterNG,
}Expand description
A RouterNG whose geometry has been built and frozen: it exposes routing
and in-place edge-weight mutation, but no method to add segments/channels or
rebuild the graph. Occupancy of a completed route is applied by adding
WIRE_COST to the existing graph edges the wire covers, so no rebuild is
needed (see Finding 1 in TUNING.md).
Fields§
§inner: RouterNGImplementations§
Source§impl ClosedRouter
impl ClosedRouter
Sourcepub fn extended(self, add: impl FnOnce(&mut Opening<'_>)) -> Self
pub fn extended(self, add: impl FnOnce(&mut Opening<'_>)) -> Self
Add geometry to a closed lattice and close it again — how a foreground is replayed onto a clone of a cached background.
Insertion only. Nothing is ever taken out: a background is built from the complement of the foreground, and the foreground is added to a clone that is thrown away afterwards. So there is no inverse operation to get wrong — no provenance to refcount, no cost to subtract, no crossing node to heal.
The lattice is re-derived from the requests rather than patched, because a channel is clipped by the blocks present when it is seeded: a block added afterwards cannot be applied to the segments that came out, and splitting them around it would invent a channel on its far side that a whole build would never have produced.
Sourcepub fn route_leg(
&mut self,
start: Point,
end: Point,
incoming: Option<Direction>,
) -> Leg
pub fn route_leg( &mut self, start: Point, end: Point, incoming: Option<Direction>, ) -> Leg
Route one leg from start to end, threading incoming (the direction
already travelled) so the leg can’t double back. Read-only w.r.t.
geometry — the graph is already closed, so the internal update() is a
no-op. Returns the path points, the outgoing direction, and whether the
lattice held a path at all.
Sourcepub fn bump_leg(&mut self, path: &[Point], cost: Cost)
pub fn bump_leg(&mut self, path: &[Point], cost: Cost)
Add cost to every graph edge along the (axis-aligned) path, leg by leg.
Sourcepub fn add_wire_cost(&mut self, a: Point, b: Point, cost: Cost)
pub fn add_wire_cost(&mut self, a: Point, b: Point, cost: Cost)
Occupy the axis-aligned wire a → b by adding cost to each of the
node-to-node graph edges it covers. Walks adjacency in the travel
direction (edges are split at every node, so each hop is one graph edge).
Never changes topology or sets dirty, so the graph stays closed and
successors reads the new weights live on the next route.
Sourcepub fn is_wire_blocked(&self, a: Point, b: Point) -> bool
pub fn is_wire_blocked(&self, a: Point, b: Point) -> bool
Whether the axis-aligned wire a → b crosses any blocked rectangle.
Sourcepub fn wire_hugs_block(&self, a: Point, b: Point) -> bool
pub fn wire_hugs_block(&self, a: Point, b: Point) -> bool
Whether the straight wire a → b hugs any block (runs within the routing
gutter alongside an edge). Complements Self::is_wire_blocked: together
they decide whether a straight leg may be taken verbatim or must route around.
pub fn is_accessible(&self, test: impl Into<Point>) -> bool
pub fn debug_marks(&self) -> Vec<Mark>
Sourcepub fn fingerprint(&self) -> Fingerprint
pub fn fingerprint(&self) -> Fingerprint
The lattice as a value that can be compared: every node, and every edge with its weight, in a canonical order. Two routers that fingerprint the same will route the same, whatever order they were assembled in — which is the property a cached background plus a replayed foreground has to hold against a whole build.
Trait Implementations§
Source§impl Clone for ClosedRouter
impl Clone for ClosedRouter
Source§fn clone(&self) -> ClosedRouter
fn clone(&self) -> ClosedRouter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more