Skip to main content

ResultList

Struct ResultList 

Source
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

Source

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.

Source

pub fn len(&self) -> Result<i32, Error>

How many results were recorded.

§Errors

Error if the COM call fails.

Source

pub fn is_empty(&self) -> Result<bool, Error>

Whether nothing was recorded.

§Errors

Error if the COM call fails.

Source

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?
examples/result_list_parse.rs (line 140)
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}
Source

pub const fn as_property_object(&self) -> &PropertyObject

The underlying array, for a caller that wants to walk it itself.

Trait Implementations§

Source§

impl Debug for ResultList

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.