1use thiserror::Error;
2use fugue::ir::{
3 Address,
4};
5pub enum HookAction<R> {
6 Pass,
7 Halt(R),
8}
9
10pub enum HookCBranchAction<R> {
11 Pass,
12 Flip,
13 Halt(R),
14}
15
16pub enum HookCallAction<R> {
17 Pass,
18 Skip,
19 Halt(R),
20}
21
22pub enum HookStepAction<R> {
23 Pass,
24 Skip,
25 Halt(R),
26 Branch((u32, Address)), }
28
29pub struct HookOutcome<A> {
32 pub action: A,
33 pub state_changed: bool,
34}
35
36impl<A> From<A> for HookOutcome<A> {
37 fn from(action: A) -> Self {
38 Self { action, state_changed: false }
39 }
40}
41
42impl<A> HookOutcome<A> {
43 pub fn state_changed(self, changed: bool) -> Self {
44 Self { state_changed: changed, ..self }
45 }
46}
47
48#[derive(Debug, Error)]
49pub enum Error<E: std::error::Error + Send + Sync + 'static> {
50 #[error(transparent)]
51 State(E),
52 #[error("Hook Error")]
53 Hook(E),
54 #[error(transparent)]
55 Other(#[from] anyhow::Error),
56}
57
58impl<E> Error<E> where E: std::error::Error + Send + Sync + 'static {
59 pub fn state(error: E) -> Self {
60 Self::State(error)
61 }
62}