1use std::fmt;
2
3use crate::RustLibPath;
4
5#[derive(Clone, Debug, Eq, PartialEq)]
7pub struct RustLibFile {
8 pub path: RustLibPath,
9 pub contents: String,
10}
11
12impl RustLibFile {
13 pub fn new(path: RustLibPath, contents: impl Into<String>) -> Self {
14 Self {
15 path,
16 contents: contents.into(),
17 }
18 }
19}
20
21#[derive(Clone, Debug, Eq, PartialEq)]
23pub struct RustLibDocs {
24 pub version: String,
26 pub documentation: String,
28}
29
30#[derive(Clone, Copy, Debug, Eq, PartialEq)]
32pub enum CheckStage {
33 Fetch,
34 Format,
35 Build,
36 Clippy,
37 Test,
38 DocTest,
39}
40
41impl CheckStage {
42 pub fn as_str(self) -> &'static str {
43 match self {
44 Self::Fetch => "fetch",
45 Self::Format => "format",
46 Self::Build => "build",
47 Self::Clippy => "clippy",
48 Self::Test => "test",
49 Self::DocTest => "doc-test",
50 }
51 }
52}
53
54impl fmt::Display for CheckStage {
55 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
56 f.write_str(self.as_str())
57 }
58}
59
60#[derive(Clone, Debug, Eq, PartialEq)]
62pub struct CheckStageResult {
63 pub stage: CheckStage,
64 pub success: bool,
65 pub exit_code: Option<i32>,
66 pub stdout: String,
67 pub stderr: String,
68}
69
70#[derive(Clone, Debug, Eq, PartialEq)]
72pub struct CheckResult {
73 pub stages: Vec<CheckStageResult>,
74}
75
76impl CheckResult {
77 pub fn passed(&self) -> bool {
79 self.stages.len() == 6 && self.stages.iter().all(|stage| stage.success)
80 }
81
82 pub fn failure(&self) -> Option<&CheckStageResult> {
84 self.stages.iter().find(|stage| !stage.success)
85 }
86}