#[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.
Fields
circumference: f64Total path length around the loop. Must be > 0 —
construction (Simulation::add_line and the explicit-topology
builder) rejects non-positive or non-finite values.
min_headway: f64Minimum permitted forward distance between successive cars.
PR 3 will add construction-time validation
(max_cars * min_headway <= circumference); until then, the
dispatch and movement code added in subsequent PRs is
responsible for behaving sanely on degenerate values.
Callers should set this strictly positive.
Implementations§
Source§impl LineKind
impl LineKind
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, initial spacing) are PR 3.
§Errors
Linear rejects non-finite or min > max bounds. Loop rejects
non-finite or non-positive circumference.