pub fn collect(kind: &TraceKind, uart: &mut Uart, buffer: PreparedBuffer, until: Instant) -> Result<TraceData> {
    // Collecting data for each trace kind is the same.
    // We are just reading bytes from the chosen serial line.

    // Shadow the buffer as a &mut [_].
    let buffer: &mut [u8] = buffer.0.as_mut_slice();
    let mut bytes_read: usize = 0;

    while Instant::now() < until {
        let read = uart.read(&mut buffer[bytes_read..])
            .unwrap();
        bytes_read += read;
    }
    println!("tracing read {} bytes", bytes_read);

    // Parsing the raw serial data is what is different.
    // Use the respective parser to recreate the structured data.
    match kind {
        TraceKind::Performance(ref _metadata) => parsing::benchmark_data(&buffer[0..bytes_read])
            .map(|(unparsed, data)| {
                println!("tracing left {} bytes unparsed", unparsed.len());
                TraceData::Performance(data)
            })
            .map_err(|e| format!("parsing error: {:?}", e)),

        _ => unimplemented!()
    }
}
/// Collect tracing data from the given UART.
Collect tracing data from the given UART.
Collect tracing data from the given UART .
pub fn collect(kind: &TraceKind, uart: &mut Uart, buffer: PreparedBuffer, until: Instant) -> Result<TraceData> {
    // Collecting data for each trace kind is the same.
    // We are just reading bytes from the chosen serial line.
    // Shadow the buffer as a &mut [_].
    let buffer: &mut [u8] = buffer.0.as_mut_slice();
    let mut bytes_read: usize = 0;
    while Instant::now() < until {
        let read = uart.read(&mut buffer[bytes_read..])
            .unwrap();
        bytes_read += read;
    }
    println!("tracing read {} bytes", bytes_read);
    // Parsing the raw serial data is what is different.
    // Use the respective parser to recreate the structured data.
    match kind {
        TraceKind::Performance(ref _metadata) => parsing::benchmark_data(&buffer[0..bytes_read])
            .map(|(unparsed, data)| {
                println!("tracing left {} bytes unparsed", unparsed.len());
                TraceData::Performance(data)
            })
            .map_err(|e| format!("parsing error: {:?}", e)),
        _ => unimplemented!()
    }
}
pub fn collect ( kind : & TraceKind , uart : & mut Uart , buffer : PreparedBuffer , until : Instant ) -> Result < TraceData > { // Collecting data for each trace kind is the same. // We are just reading bytes from the chosen serial line. // Shadow the buffer as a &mut [_]. let buffer : & mut [ u8 ] = buffer . 0 . as_mut_slice ( ) ; let mut bytes_read : usize = 0 ; while Instant :: now ( ) < until { let read = uart . read ( & mut buffer [ bytes_read .. ] ) . unwrap ( ) ; bytes_read += read ; } println ! ( " " bytes_read ) ; // Parsing the raw serial data is what is different. // Use the respective parser to recreate the structured data. match kind { TraceKind :: Performance ( ref _metadata ) => parsing :: benchmark_data ( & buffer [ 0 .. bytes_read ] ) . map ( | ( unparsed , data ) | { println ! ( " " unparsed len ( ) ) ; TraceData :: Performance ( data ) } ) . map_err ( | e | format ! ( " " e ) ) , _ => unimplemented ! ( ) } }
Collect tracing data from the given UART.
Collect tracing data from the given UART .
kind
&TraceKind
uart
&mut Uart
buffer
PreparedBuffer
until
Instant
kind
&TraceKind
uart
&mut Uart
buffer
PreparedBuffer
until
Instant