#[non_exhaustive]pub enum LineKind {
Linear {
min: f64,
max: f64,
},
Loop {
circumference: f64,
min_headway: f64,
},
}Expand description
Topology of a line — open-ended linear axis or closed loop.
Linear is the default for elevator shafts, tethers, and other paths
bounded by [min, max]. Loop (gated behind the loop_lines
feature) models a closed-loop transit line where positions wrap
modulo circumference. Helpers in super::cyclic operate on Loop
positions; consumer code dispatches on this enum to pick linear vs
cyclic semantics.
#[non_exhaustive] — future topologies (figure-eight, branching, etc.)
can be added without a major version bump.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Linear
Open-ended line with hard [min, max] position bounds. Cars
reverse at endpoints; this matches every existing dispatch
strategy (LOOK, sweep, scan, destination, etc.).
Loop
Closed loop with cyclic position semantics. Positions wrap into
[0, circumference); cars travel one direction only and
maintain a strict no-overtake ordering with at least
min_headway between successive cars.
Implementations§
Source§impl LineKind
impl LineKind
Sourcepub const fn is_loop(&self) -> bool
pub const fn is_loop(&self) -> bool
Returns true for LineKind::Loop; paired with Self::is_linear.
Sourcepub const fn is_linear(&self) -> bool
pub const fn is_linear(&self) -> bool
Whether this line is a (linear) open-ended axis.
Paired with Self::is_loop so consumers can dispatch positively
on the expected variant rather than negatively on “not Loop”, which
would silently absorb any future topology added to the enum.
Sourcepub fn validate(&self) -> Result<(), (&'static str, String)>
pub fn validate(&self) -> Result<(), (&'static str, String)>
Validate that this kind’s intrinsic bounds are well-formed.
Returns Err((field, reason)) on a violation; both construction
entry points (Simulation::add_line
and the explicit-topology builder) call this and lift the error
into SimError::InvalidConfig.
The intent is the trivial per-kind sanity checks — bounds finite
and ordered, circumference positive. Cross-line invariants
(max_cars × headway, group homogeneity) are checked by the
Simulation construction and topology methods, not here.
§Errors
Linear rejects non-finite or min > max bounds. Loop rejects
non-finite or non-positive circumference.