#[cfg(any(target_os = "linux", target_os = "macos"))]
mod unix;

#[cfg(target_os = "windows")]
mod windows;

#[cfg(any(target_os = "linux", target_os = "macos"))]
pub use unix::{find_processes_by_port, kill_process};

#[cfg(target_os = "windows")]
pub use windows::{find_processes_by_port, kill_process};

#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
use crate::error::PortKillerError;
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
use crate::models::ProcessInfo;
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
use crate::Result;

#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
pub fn find_processes_by_port(_port: u16) -> Result<Vec<ProcessInfo>> {
    Err(PortKillerError::UnsupportedPlatform(
        std::env::consts::OS.to_string(),
    ))
}

#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
pub fn kill_process(_pid: u32, _force: bool) -> Result<()> {
    Err(PortKillerError::UnsupportedPlatform(
        std::env::consts::OS.to_string(),
    ))
}
