troll 0.4.0

The port manager that guards the bridge: permanent claims, expiring leases, and a live view of who listens where.
use std::{env, ops::RangeInclusive, path::PathBuf};

use troll_core::ProbeError;
use troll_probe::SystemProbe;

use crate::error::CliError;

use super::unix::troll_home;

const APP_SUPPORT: &str = "Library/Application Support";

pub fn config_home() -> Result<PathBuf, CliError> {
    troll_home(
        env::var_os("XDG_CONFIG_HOME").as_deref(),
        env::var_os("HOME").as_deref(),
        APP_SUPPORT,
    )
    .ok_or(CliError::MissingConfigHome)
}

pub fn data_home() -> Result<PathBuf, CliError> {
    troll_home(
        env::var_os("XDG_DATA_HOME").as_deref(),
        env::var_os("HOME").as_deref(),
        APP_SUPPORT,
    )
    .ok_or(CliError::MissingDataHome)
}

pub fn state_home() -> Result<PathBuf, CliError> {
    troll_home(
        env::var_os("XDG_STATE_HOME").as_deref(),
        env::var_os("HOME").as_deref(),
        APP_SUPPORT,
    )
    .ok_or(CliError::MissingStateHome)
}

pub fn require_listener_probe(_probe: &SystemProbe) -> Result<(), ProbeError> {
    Ok(())
}

pub fn setup_ephemeral_range() -> Result<Option<RangeInclusive<u16>>, ProbeError> {
    troll_probe::ephemeral_range()
}

pub fn proc_probe() -> SystemProbe {
    SystemProbe::new()
}