pub struct Topology { /* private fields */ }Expand description
Shared planar layers and ordered rules with reusable, thread-safe geometry caches.
Implementations§
Source§impl Topology
impl Topology
Sourcepub fn new(tolerance: f64) -> Result<Self, Error>
pub fn new(tolerance: f64) -> Result<Self, Error>
Create an empty topology with tolerance in input coordinate units. Zero requests exact comparisons; no CRS transformation is performed.
§Errors
Returns Error::Tolerance for a negative or non-finite tolerance.
Sourcepub fn add_layer(&mut self, layer: impl Into<Arc<Layer>>) -> LayerId
pub fn add_layer(&mut self, layer: impl Into<Arc<Layer>>) -> LayerId
Register a layer without validating it, returning a topology-scoped ID.
Pass an Arc<Layer> to share one layer, and its cached views, between topologies.
Sourcepub fn layer(&self, id: LayerId) -> Result<&Layer, Error>
pub fn layer(&self, id: LayerId) -> Result<&Layer, Error>
Borrow a registered layer. IDs must originate from this topology.
§Errors
Returns Error::UnknownLayer when the index is not registered.
Sourcepub fn layers(&self) -> impl Iterator<Item = (LayerId, &Layer)>
pub fn layers(&self) -> impl Iterator<Item = (LayerId, &Layer)>
Iterate layers and their IDs in registration order.
Sourcepub fn rules(&self) -> impl ExactSizeIterator<Item = RuleSpec>
pub fn rules(&self) -> impl ExactSizeIterator<Item = RuleSpec>
Iterate registered rules in registration order.
Sourcepub fn clear_rules(&mut self)
pub fn clear_rules(&mut self)
Remove every registered rule, keeping layers and their cached line graphs, so a different rule set can be validated without rebuilding them. Rule IDs restart at zero; IDs from earlier registrations must not be reused.
Sourcepub fn add_rule(
&mut self,
rule: Rule,
layer: LayerId,
other: Option<LayerId>,
) -> Result<RuleSpec, Error>
pub fn add_rule( &mut self, rule: Rule, layer: LayerId, other: Option<LayerId>, ) -> Result<RuleSpec, Error>
Register a rule after validating input families, finite coordinates and FIDs.
Unary rules require no secondary layer; binary rules require a distinct one.
Rules run in parallel, but reports retain registration order.
The returned spec’s id locates this rule’s result with Report::rule.
§Errors
Returns input-count, same-layer, unknown-layer, geometry-kind, duplicate-FID or non-finite-coordinate errors. Failed registration does not add a rule.
Sourcepub fn register_rule(
&mut self,
rule: Rule,
layer: LayerInput,
other: Option<LayerInput>,
) -> Result<RuleSpec, Error>
pub fn register_rule( &mut self, rule: Rule, layer: LayerInput, other: Option<LayerInput>, ) -> Result<RuleSpec, Error>
Validate and commit owned inputs and a rule as one transaction. Layer caches do not depend on registration IDs, so validation work done here is reused after commit.
§Errors
Returns arity, same-layer, unknown-layer, geometry-kind, duplicate-FID or coordinate errors before committing any new layer or rule.
Sourcepub fn warnings(&self) -> Result<Vec<Warning>, Error>
pub fn warnings(&self) -> Result<Vec<Warning>, Error>
Validate cached part views and report skipped degenerate parts without running rules.
§Errors
Returns duplicate-FID or non-finite-coordinate errors from any registered layer, including layers that are not used by a rule.
Sourcepub fn validate(&self) -> Result<Report, Error>
pub fn validate(&self) -> Result<Report, Error>
Validate all layers and execute registered rules, reusing cached views. Topology violations are a successful report, not operational errors.
§Errors
Returns invalid-layer errors from deferred validation or operational errors encountered while building rule inputs. No partial report is returned.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Topology
impl RefUnwindSafe for Topology
impl Send for Topology
impl Sync for Topology
impl Unpin for Topology
impl UnsafeUnpin for Topology
impl UnwindSafe for Topology
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more