fn loop_through<T: Write>(&mut self, output: &mut T) -> Result<()> {
        let mut model = match self.get_advance_mut().advance(Direction::Forward) {
            Some(m) => m,
            None => bail!("No initial model could be found!"),
        };

        let json = self.get_opts().output_format == Some(OutputFormat::Json);
        let csv = self.get_opts().output_format == Some(OutputFormat::Csv);

        let mut round = 0;

        if json {
            write!(output, "[")?;
        }

        loop {
            self.advance_timestamp(&model)?;

            // Base on the exec result, we will determine if we need to generate the line breaker, etc
            let comma_flag = round != 0;
            let exec_res = match self.iterate_exec(&model, output, &mut round, comma_flag) {
                Ok(res) => res,
                // Swallow BrokenPipe error for write. Rust runtime will ignore SIGPIPE by default and
                // propagating EPIPE upwards to the application in the form of an IoError::BrokenPipe.
                Err(e)
                    if e.downcast_ref::<std::io::Error>()
                        .map_or_else(|| false, |e| e.kind() == std::io::ErrorKind::BrokenPipe) =>
                {
                    return Ok(())
                }
                Err(e) => return Err(e),
            };

            if self.get_advance().get_next_ts() > *self.get_time_end() {
                break;
            }

            model = match self.get_advance_mut().advance(Direction::Forward) {
                Some(m) => m,
                None => break,
            };

            if exec_res == IterExecResult::Skip {
                continue;
            }

            if !csv {
                write!(output, "\n")?;
            }
        }

        if json {
            write!(output, "]")?;
        }

        Ok(())
    }
// The main event loop. This function will call iterate_exec on each timeslice.
The main event loop. This function will call iterate_exec on each timeslice.
The main event loop . This function will call iterate_exec on each timeslice .
fn loop_through<T: Write>(&mut self, output: &mut T) -> Result<()> {
        let mut model = match self.get_advance_mut().advance(Direction::Forward) {
            Some(m) => m,
            None => bail!("No initial model could be found!"),
        };
        let json = self.get_opts().output_format == Some(OutputFormat::Json);
        let csv = self.get_opts().output_format == Some(OutputFormat::Csv);
        let mut round = 0;
        if json {
            write!(output, "[")?;
        }
        loop {
            self.advance_timestamp(&model)?;
            // Base on the exec result, we will determine if we need to generate the line breaker, etc
            let comma_flag = round != 0;
            let exec_res = match self.iterate_exec(&model, output, &mut round, comma_flag) {
                Ok(res) => res,
                // Swallow BrokenPipe error for write. Rust runtime will ignore SIGPIPE by default and
                // propagating EPIPE upwards to the application in the form of an IoError::BrokenPipe.
                Err(e)
                    if e.downcast_ref::<std::io::Error>()
                        .map_or_else(|| false, |e| e.kind() == std::io::ErrorKind::BrokenPipe) =>
                {
                    return Ok(())
                }
                Err(e) => return Err(e),
            };
            if self.get_advance().get_next_ts() > *self.get_time_end() {
                break;
            }
            model = match self.get_advance_mut().advance(Direction::Forward) {
                Some(m) => m,
                None => break,
            };
            if exec_res == IterExecResult::Skip {
                continue;
            }
            if !csv {
                write!(output, "\n")?;
            }
        }
        if json {
            write!(output, "]")?;
        }
        Ok(())
    }
fn loop_through < T : Write > ( & mut self , output : & mut T ) -> Result < ( ) > { let mut model = match self . get_advance_mut ( ) . advance ( Direction :: Forward ) { Some ( m ) => m , None => bail ! ( " " ) , } ; let json = self . get_opts ( ) . output_format == Some ( OutputFormat :: Json ) ; let csv = self . get_opts ( ) . output_format == Some ( OutputFormat :: Csv ) ; let mut round = 0 ; if json { write ! ( output " " ) ? ; } loop { self . advance_timestamp ( & model ) ? ; // Base on the exec result, we will determine if we need to generate the line breaker, etc let comma_flag = round != 0 ; let exec_res = match self . iterate_exec ( & model , output , & mut round , comma_flag ) { Ok ( res ) => res , // Swallow BrokenPipe error for write. Rust runtime will ignore SIGPIPE by default and // propagating EPIPE upwards to the application in the form of an IoError::BrokenPipe. Err ( e ) if e . downcast_ref :: < std :: io :: Error > ( ) . map_or_else ( | | false , | e | e . kind ( ) == std :: io :: ErrorKind :: BrokenPipe ) => { return Ok ( ( ) ) } Err ( e ) => return Err ( e ) , } ; if self . get_advance ( ) . get_next_ts ( ) > * self . get_time_end ( ) { break ; } model = match self . get_advance_mut ( ) . advance ( Direction :: Forward ) { Some ( m ) => m , None => break , } ; if exec_res == IterExecResult :: Skip { continue ; } if ! csv { write ! ( output " \n " ) ? ; } } if json { write ! ( output " " ) ? ; } Ok ( ( ) ) }
The main event loop.
The main event loop .
&mut self
output
&mut T
&mut self
output
&mut T