1use std::convert:: { From };
12use std::option:: { Option };
13use std::io:: { Result };
14use std::io::prelude::*;
15use parser:: { parse_record };
16
17#[derive(Debug, PartialEq, Clone)]
18pub enum LCOVRecord
19{
20 TestName(Option<String>), SourceFile(String), Data(LineData), FunctionName(FunctionName), FunctionData(FunctionData), FunctionsFound(u32), FunctionsHit(u32), LinesHit(u32), LinesFound(u32), BranchData(BranchData), BranchesFound(u32), BranchesHit(u32), EndOfRecord }
34
35#[derive(Debug, PartialEq, Clone)]
36pub struct LineData {
37 pub line: u32,
38 pub count: u32,
39 pub checksum: Option<String> }
41
42#[derive(Debug, PartialEq, Clone)]
43pub struct FunctionName {
44 pub name: String,
45 pub line: u32
46}
47
48#[derive(Debug, PartialEq, Clone)]
49pub struct FunctionData {
50 pub name: String,
51 pub count: u32
52}
53
54#[derive(Debug, PartialEq, Clone)]
55pub struct BranchData {
56 pub line: u32,
57 pub block: u32,
58 pub branch: u32,
59 pub taken: u32
60}
61
62impl<'a> From<&'a str> for LCOVRecord {
75 fn from(input: &'a str) -> Self {
76 parse_record(input).unwrap()
77 }
78}
79
80impl From<LineData> for LCOVRecord {
81 fn from(input: LineData) -> Self {
82 LCOVRecord::Data(input)
83 }
84}
85
86impl From<FunctionName> for LCOVRecord {
87 fn from(input: FunctionName) -> Self {
88 LCOVRecord::FunctionName(input)
89 }
90}
91
92impl From<FunctionData> for LCOVRecord {
93 fn from(input: FunctionData) -> Self {
94 LCOVRecord::FunctionData(input)
95 }
96}
97
98impl From<BranchData> for LCOVRecord {
99 fn from(input: BranchData) -> Self {
100 LCOVRecord::BranchData(input)
101 }
102}
103
104pub trait RecordWrite {
105 fn write_records<T: Write>(&self, output: &mut T) -> Result<()>;
106}