ghidra 0.0.3

Typed Rust bindings for an embedded Ghidra JVM
Documentation
use std::time::Duration;

use crate::{Result, TaskMonitorOptions};

/// Options for a single decompile request.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DecompileOptions {
    /// Decompiler timeout in seconds.
    pub timeout_seconds: u64,
    /// Optional task monitor timeout applied to the bridge call.
    pub monitor: TaskMonitorOptions,
}

impl DecompileOptions {
    /// Creates decompile options with a timeout in seconds and no task monitor timeout.
    pub const fn new(timeout_seconds: u64) -> Self {
        Self {
            timeout_seconds,
            monitor: TaskMonitorOptions::none(),
        }
    }

    /// Sets explicit task monitor options for the decompile bridge call.
    pub fn with_monitor(mut self, monitor: TaskMonitorOptions) -> Self {
        self.monitor = monitor;
        self
    }

    /// Sets a task monitor timeout for the decompile bridge call.
    pub fn with_monitor_timeout(mut self, timeout: Duration) -> Result<Self> {
        self.monitor = TaskMonitorOptions::timeout(timeout)?;
        Ok(self)
    }
}