cradle_plugin_api/
checks.rs1use cradle_shared::CheckResult;
2use std::ffi::c_void;
3
4pub struct PluginResults {
7 plugin: &'static str,
8 results: Vec<CheckResult>,
9}
10
11impl PluginResults {
12 pub fn new(plugin: &'static str) -> Self {
14 Self {
15 plugin,
16 results: Vec::new(),
17 }
18 }
19 pub fn pass(&mut self, check: &str, msg: impl Into<String>) {
21 self.results
22 .push(CheckResult::pass(self.plugin, check, msg));
23 }
24
25 pub fn warn(&mut self, check: &str, msg: impl Into<String>) {
27 self.results
28 .push(CheckResult::warn(self.plugin, check, msg));
29 }
30
31 pub fn fail(&mut self, check: &str, msg: impl Into<String>) {
33 self.results
34 .push(CheckResult::fail(self.plugin, check, msg));
35 }
36
37 pub fn info(&mut self, check: &str, msg: impl Into<String>) {
39 self.results
40 .push(CheckResult::info(self.plugin, check, msg));
41 }
42
43 pub fn warn_with(&mut self, check: &str, msg: impl Into<String>, details: impl Into<String>) {
45 self.results
46 .push(CheckResult::warn(self.plugin, check, msg).with_details(details));
47 }
48
49 pub fn fail_with(&mut self, check: &str, msg: impl Into<String>, details: impl Into<String>) {
51 self.results
52 .push(CheckResult::fail(self.plugin, check, msg).with_details(details));
53 }
54
55 pub fn push(&mut self, result: CheckResult) {
57 self.results.push(result);
58 }
59
60 pub fn take(&mut self) -> Vec<CheckResult> {
62 std::mem::take(&mut self.results)
63 }
64
65 pub fn len(&self) -> usize {
67 self.results.len()
68 }
69
70 pub fn is_empty(&self) -> bool {
72 self.results.is_empty()
73 }
74}
75
76#[non_exhaustive]
78pub enum AgentEvent<'a> {
79 ProcessCreated {
81 pid: u32,
83 process: *mut c_void,
85 target_path: &'a str,
87 target_bytes: &'a [u8],
89 },
90 DllLoaded {
92 name: &'a str,
94 base: usize,
96 },
97 InitialBreakpoint,
99 ThreadCreated {
101 tid: u32,
103 handle: *mut c_void,
105 },
106 Finished,
108 ThreadFinished {
110 tid: u32,
112 },
113 DebugString {
115 string: &'a str,
117 },
118 AgentInitialized {
120 target_path: &'a str,
122 },
123 AgentFinished,
125 Unknown,
127}