1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use std::io;
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("Read error: {0}")]
Read(#[from] ReadError),
#[error("I/O error: {0}")]
IoError(#[from] io::Error),
#[error("Did not recognize magic value {0:?}")]
UnrecognizedMagicValue([u8; 8]),
#[error("Section size did not fit into usize")]
SectionSizeTooBig,
#[error("The section wasn't big enough to contain the u32 string length")]
NotEnoughSpaceForStringLen,
#[error("The section wasn't big enough to contain the NrCpus struct")]
NotEnoughSpaceForNrCpus,
#[error("The indicated string length wouldn't fit in the indicated section size")]
StringLengthTooLong,
#[error("The indicated string length wouldn't fit into usize")]
StringLengthBiggerThanUsize,
#[error("The string was not valid utf-8")]
StringUtf8,
#[error("The specified size in the perf event header was smaller than the header itself")]
InvalidPerfEventSize,
}
#[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)]
pub enum ReadError {
#[error("Could not read PerfHeader")]
PerfHeader,
#[error("Could not read PerFlagSection")]
PerFlagSection,
#[error("Could not read BuildIdSection")]
BuildIdSection,
#[error("Could not read StringLen")]
StringLen,
#[error("Could not read String")]
String,
#[error("Could not read NrCpus")]
NrCpus,
#[error("Could not read AttrsSection")]
AttrsSection,
#[error("Could not read PerfEventAttr")]
PerfEventAttr,
#[error("Could not read PerfEventHeader")]
PerfEventHeader,
#[error("Could not read PerfEvent data")]
PerfEventData,
}