silk.machine.paths.
Paths through a chart: how to reach each state, and which states cannot be reached.
When to use#
Use Paths.shortest to write one test per state without working out the events by hand,
and Paths.unreachable in a test or a build step to catch a state that no transition
leads to.
Details#
A path is found in one chart of a Definition, from its initial state, with the fewest
steps. Every transition counts as possible, guarded or not, so a path says how a state can
be reached when the guards allow it. A step is the event's name, always for an eventless
transition, or after <duration> for a delayed one, such as after 2s. The transition
that any event takes is the step *.
Gotchas#
Regions are charts of their own. A path does not cross from a chart into the chart of a region: ask for the region's chart by its name.
Import as Paths with import silk.machine.paths { Paths }.
Public declarations: 2.
Path#
pub struct PathThe steps that lead from the initial state of a chart to state.
Field state#
pub state: StringField steps#
pub steps: List<String>One entry per transition, in order. Empty for the initial state.
Paths#
pub struct PathsImplementation Paths#
impl PathsAssociated function shortest#
pub effect fn shortest(definition: &Definition, chart: string) -> List<Path>
! OutOfMemoryError
? &mut AllocatorReturns a shortest path to every state of the chart called chart that can be reached,
the initial state first. A chart the definition does not have gives no paths.
Associated function unreachable#
pub effect fn unreachable(definition: &Definition, chart: string) -> List<String>
! OutOfMemoryError
? &mut AllocatorReturns the names of the states of the chart called chart that no path reaches.
Category: State machines.
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2, x86_64-pc-windows-msvc, wasm64-unknown-unknown.