pub struct ResultList { /* private fields */ }Expand description
An execution’s recorded results (ResultList).
A thin reader over the array the engine builds as a sequence runs. Only
steps whose recording is enabled appear here, so the list is routinely
shorter than the sequence, and a step that failed early can end a run before
later steps record anything. See
ResultRecordingOption.
Implementations§
Source§impl ResultList
impl ResultList
Sourcepub fn from_result_object(result_object: &PropertyObject) -> Result<Self, Error>
pub fn from_result_object(result_object: &PropertyObject) -> Result<Self, Error>
Reads results from anything that exposes a ResultList property.
Accepts the results tree from
Execution::result_object, which is
where a headless caller finds them.
§Errors
Error if the object holds no ResultList, or a COM call fails.
Sourcepub fn parse(&self) -> Result<Vec<StepResult>, Error>
pub fn parse(&self) -> Result<Vec<StepResult>, Error>
Reads every result into plain data.
Each field is optional in the tree, and a missing one is normal rather
than an error: an action step records no measurement, and a result
written by a custom step type may carry neither name nor type. Missing
text becomes empty, a missing measurement becomes None.
§Errors
Error if the list cannot be walked.
Examples found in repository?
109fn main() -> Result<(), Box<dyn std::error::Error>> {
110 let engine = Engine::new()?;
111 engine.set_ui_message_polling_enabled(true)?;
112
113 let sequence_file = engine.new_sequence_file()?;
114 let main_sequence = sequence_file.get_sequence_by_name("MainSequence")?;
115
116 add_pass_fail(&engine, &main_sequence, "Verify Power Rail", "True")?;
117 add_unrecorded_filler(&engine, &main_sequence, "Filler (not recorded)")?;
118 add_numeric(
119 &engine,
120 &main_sequence,
121 "Verify Current Draw",
122 "1.5",
123 1.0,
124 2.0,
125 )?;
126 add_pass_fail(&engine, &main_sequence, "Verify Ground Bond", "True")?;
127
128 let step_count = main_sequence.get_num_steps(StepGroup::Main)?;
129 println!("Running {step_count} steps...");
130 let execution = engine.new_execution(&sequence_file, "MainSequence", None, false, 0)?;
131
132 if !wait_for_end(&engine, RUN_DEADLINE)? {
133 println!("The run did not finish within {RUN_DEADLINE:?}; terminating.");
134 execution.terminate()?;
135 return Ok(());
136 }
137 println!("Finished with status: {}\n", execution.result_status()?);
138
139 let results = execution.result_list()?;
140 let parsed = results.parse()?;
141
142 println!("{} of {step_count} steps recorded a result:", parsed.len());
143 for (index, result) in parsed.iter().enumerate() {
144 let measurement = match &result.value {
145 Some(ResultValue::Number(number)) => format!("measured {number}"),
146 Some(ResultValue::Text(text)) => format!("measured {text:?}"),
147 None => "no measurement".to_owned(),
148 };
149 println!(
150 " [{index}] {} ({}) -> {}, {measurement}",
151 result.name, result.step_type, result.status
152 );
153 }
154
155 // The step whose recording was switched off is absent, by design.
156 println!(
157 "\nThe unrecorded step left no entry, which is why {} < {step_count}.",
158 parsed.len()
159 );
160
161 // The parsed results are plain data, so they outlive the run and can be
162 // handed to anything: a report writer, a database, a serde format.
163 let failures: Vec<&str> = parsed
164 .iter()
165 .filter(|result| result.status == "Failed")
166 .map(|result| result.name.as_str())
167 .collect();
168 if failures.is_empty() {
169 println!("No failures.");
170 } else {
171 println!("Failed steps: {}", failures.join(", "));
172 }
173
174 engine.release_sequence_file_ex(sequence_file, none())?;
175 Ok(())
176}Sourcepub const fn as_property_object(&self) -> &PropertyObject
pub const fn as_property_object(&self) -> &PropertyObject
The underlying array, for a caller that wants to walk it itself.