Hi,
in my app the user has to load/record multiple measurements as prerequisite for further analysis of these measurements. The prerequisites are:
- one
Loopback
measurement - at least one
Measurement
Currently I use this to hold the state:
#[derive(Debug, Clone)]
enum MeasurementsState {
Collecting {
loopback: Option<MeasurementState<data::Loopback>>,
measurements: Vec<MeasurementState<data::Measurement>>,
},
Analysing {
loopback: data::Loopback,
measurements: Vec<data::Measurement>,
},
}
#[derive(Debug, Clone)]
enum MeasurementState<T> {
NotLoaded(OfflineMeasurement),
Loaded(T),
}
But my current implementation of the state transition is very bloated.
There is probably a better way to implement this.
edit
In the meantime I came up with this playground example.
But, it would still be nicer to encode the valid data into the AnalysisState::DataReady
state.