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
//! Errors that can occur in the qemu-plugin crate

#[derive(thiserror::Error, Debug)]
/// An error from the qemu-plugin crate
pub enum Error {
    #[error("Missing key for argument {argument}")]
    /// Error when an argument is missing a key
    MissingArgKey {
        /// The argument string a key is missing for
        argument: String,
    },
    #[error("Missing value for argument {argument}")]
    /// Error when an argument is missing a value
    MissingArgValue {
        /// The argument string a value is missing for
        argument: String,
    },
    #[error("Invalid boolean value {name} ({val})")]
    /// Error when a boolean argument is invalid
    InvalidBool {
        /// The name of the key-value argument pair which does not correctly parse as boolean
        name: String,
        /// The value of the key-value argument pair which does not correctly parse as boolean
        val: String,
    },
    #[error("Setting the QEMU plugin uninstall callback was attempted concurrently and this attempt failed.")]
    /// Error when the QEMU plugin uninstall callback is set concurrently
    ConcurrentPluginUninstallCallbackSet,
    #[error("Setting the QEMU plugin reset callback was attempted concurrently and this attempt failed.")]
    /// Error when the QEMU plugin reset callback is set concurrently
    ConcurrentPluginResetCallbackSet,
    #[error("Invalid state for plugin reset callback")]
    /// Error when the plugin reset callback is in an invalid state
    PluginResetCallbackState,
    #[error("Invalid instruction index {index} for translation block of size {size}")]
    /// Error when an instruction index is invalid
    InvalidInstructionIndex {
        /// The index into the translation block that is invalid
        index: usize,
        /// The size of the translation block
        size: usize,
    },
    #[error("No disassembly string available for instruction")]
    /// Error when no disassembly string is available for an instruction (i.e. NULL string
    NoDisassemblyString,
    #[error(transparent)]
    /// A transparently wrapped `std::str::Utf8Error`
    Utf8Error(#[from] std::str::Utf8Error),
    #[error(transparent)]
    /// A transparently wrapped `std::ffi::NulError`
    NulError(#[from] std::ffi::NulError),
    #[error(transparent)]
    /// A transparently wrapped `anyhow::Error`
    Other(#[from] anyhow::Error),
}

/// Result type for the qemu-plugin crate
pub type Result<T> = std::result::Result<T, Error>;