fn rec_align<'a>(t0: Instant,
                     tp: Instant,
                     conditions: &[SerialTraceCondition],
                     events: &'a [SerialTrace]) -> Option<Vec<&'a SerialTrace>>
    {
        let mut matches = Vec::new();

        if conditions.len() > 0 {
            let condition = &conditions[0];
            for (event, idx) in events.iter().zip(0..) {
                if condition.satisfied_by(event) {
                    let timing_matches: bool = {
                        if let Some(timing) = condition.get_offset() {
                            let t_req = match timing {
                                Timing::Absolute(d) => t0 + d,
                                Timing::Relative(d) => tp + d,
                            };

                            let since = t_req.max(event.get_time()) - t_req.min(event.get_time());
                            since < condition.get_tolerance().unwrap()
                        } else {
                            true
                        }
                    };

                    if timing_matches {
                        let rest = SerialTraceCriterion::rec_align(
                            t0, event.get_time(), &conditions[1..], &events[idx+1..]);
                        if let Some(rest) = rest {
                            matches.push(event);
                            matches.extend(rest.into_iter());

                            return Some(matches);
                        }
                    }
                }
            }

            None
        } else {
            Some(Vec::new())
        }
    }
/** Attempt to satisfy conditions with the provided [`SerialTrace`]s.

    # Algorithm overview

    Advances through:
    - ordering of trace conditions
    - sequence of trace events captured during the test

    For each trace condition, advances through the trace events to find a matching trace event.
    Upon finding a matching trace condition, the function advances to the next trace condition.
    If a trace condition fails to find a matching trace event, then we back out to the previous trace condition.
    The previous trace condition seeks another matching trace event.
    If a trace condition advances to the last trace event and does not find a match, then the function returns false.
     */
Attempt to satisfy conditions with the provided [`SerialTrace`]s.
Attempt to satisfy conditions with the provided [ ` SerialTrace ` ] s .
fn rec_align<'a>(t0: Instant,
                     tp: Instant,
                     conditions: &[SerialTraceCondition],
                     events: &'a [SerialTrace]) -> Option<Vec<&'a SerialTrace>>
    {
        let mut matches = Vec::new();
        if conditions.len() > 0 {
            let condition = &conditions[0];
            for (event, idx) in events.iter().zip(0..) {
                if condition.satisfied_by(event) {
                    let timing_matches: bool = {
                        if let Some(timing) = condition.get_offset() {
                            let t_req = match timing {
                                Timing::Absolute(d) => t0 + d,
                                Timing::Relative(d) => tp + d,
                            };
                            let since = t_req.max(event.get_time()) - t_req.min(event.get_time());
                            since < condition.get_tolerance().unwrap()
                        } else {
                            true
                        }
                    };
                    if timing_matches {
                        let rest = SerialTraceCriterion::rec_align(
                            t0, event.get_time(), &conditions[1..], &events[idx+1..]);
                        if let Some(rest) = rest {
                            matches.push(event);
                            matches.extend(rest.into_iter());
                            return Some(matches);
                        }
                    }
                }
            }
            None
        } else {
            Some(Vec::new())
        }
    }
fn rec_align < ' a > ( t0 : Instant , tp : Instant , conditions : & [ SerialTraceCondition ] , events : & ' a [ SerialTrace ] ) -> Option < Vec < & ' a SerialTrace > > { let mut matches = Vec :: new ( ) ; if conditions . len ( ) > 0 { let condition = & conditions [ 0 ] ; for ( event , idx ) in events . iter ( ) . zip ( 0 .. ) { if condition . satisfied_by ( event ) { let timing_matches : bool = { if let Some ( timing ) = condition . get_offset ( ) { let t_req = match timing { Timing :: Absolute ( d ) => t0 + d , Timing :: Relative ( d ) => tp + d , } ; let since = t_req . max ( event . get_time ( ) ) - t_req . min ( event . get_time ( ) ) ; since < condition . get_tolerance ( ) . unwrap ( ) } else { true } } ; if timing_matches { let rest = SerialTraceCriterion :: rec_align ( t0 , event . get_time ( ) , & conditions [ 1 .. ] , & events [ idx + 1 .. ] ) ; if let Some ( rest ) = rest { matches . push ( event ) ; matches . extend ( rest . into_iter ( ) ) ; return Some ( matches ) ; } } } } None } else { Some ( Vec :: new ( ) ) } }
Attempt to satisfy conditions with the provided [`SerialTrace`]s.
Attempt to satisfy conditions with the provided [ ` SerialTrace ` ] s .
t0
Instant
tp
Instant
conditions
&[SerialTraceCondition]
events
&'a [SerialTrace]
t0
Instant
tp
Instant
conditions
&[SerialTraceCondition]
events
&'a [SerialTrace]
algorithm overview
Advances through:
ordering of trace conditions
sequence of trace events captured during the test

For each trace condition, advances through the trace events to find a matching trace event.
Upon finding a matching trace condition, the function advances to the next trace condition.
If a trace condition fails to find a matching trace event, then we back out to the previous trace condition.
The previous trace condition seeks another matching trace event.
If a trace condition advances to the last trace event and does not find a match, then the function returns false.
Advances through : ordering of trace conditions sequence of trace events captured during the test For each trace condition advances through the trace events to find a matching trace event . Upon finding a matching trace condition the function advances to the next trace condition . If a trace condition fails to find a matching trace event then we back out to the previous trace condition . The previous trace condition seeks another matching trace event . If a trace condition advances to the last trace event and does not find a match then the function returns false .