use cradle_shared::CheckResult;
use std::ffi::c_void;
pub struct PluginResults {
plugin: &'static str,
results: Vec<CheckResult>,
}
impl PluginResults {
pub fn new(plugin: &'static str) -> Self {
Self {
plugin,
results: Vec::new(),
}
}
pub fn pass(&mut self, check: &str, msg: impl Into<String>) {
self.results
.push(CheckResult::pass(self.plugin, check, msg));
}
pub fn warn(&mut self, check: &str, msg: impl Into<String>) {
self.results
.push(CheckResult::warn(self.plugin, check, msg));
}
pub fn fail(&mut self, check: &str, msg: impl Into<String>) {
self.results
.push(CheckResult::fail(self.plugin, check, msg));
}
pub fn info(&mut self, check: &str, msg: impl Into<String>) {
self.results
.push(CheckResult::info(self.plugin, check, msg));
}
pub fn warn_with(&mut self, check: &str, msg: impl Into<String>, details: impl Into<String>) {
self.results
.push(CheckResult::warn(self.plugin, check, msg).with_details(details));
}
pub fn fail_with(&mut self, check: &str, msg: impl Into<String>, details: impl Into<String>) {
self.results
.push(CheckResult::fail(self.plugin, check, msg).with_details(details));
}
pub fn push(&mut self, result: CheckResult) {
self.results.push(result);
}
pub fn take(&mut self) -> Vec<CheckResult> {
std::mem::take(&mut self.results)
}
pub fn len(&self) -> usize {
self.results.len()
}
pub fn is_empty(&self) -> bool {
self.results.is_empty()
}
}
#[non_exhaustive]
pub enum AgentEvent<'a> {
ProcessCreated {
pid: u32,
process: *mut c_void,
target_path: &'a str,
target_bytes: &'a [u8],
},
DllLoaded {
name: &'a str,
base: usize,
},
InitialBreakpoint,
ThreadCreated {
tid: u32,
handle: *mut c_void,
},
Finished,
ThreadFinished {
tid: u32,
},
DebugString {
string: &'a str,
},
AgentInitialized {
target_path: &'a str,
},
AgentFinished,
Unknown,
}