config-resolver 0.2.1

A modular configuration resolver for auto-detecting and resolving runtime values (IPs, ports, peer IDs)
Documentation
use crate::error::Error;
use crate::types::ResolvedValue;
use async_trait::async_trait;

/// A trait for providing configuration values dynamically.
#[async_trait]
pub trait ConfigProvider: Send + Sync {
    /// Returns the unique name of the provider (e.g., "AWS_PUBLIC_IP").
    fn name(&self) -> &str;

    /// Resolves the configuration value asynchronously.
    async fn resolve(&self) -> Result<ResolvedValue, Error>;

    /// Resolves the configuration value synchronously.
    fn resolve_sync(&self) -> Result<ResolvedValue, Error> {
        Err(Error::SyncResolutionNotSupported(self.name().to_string()))
    }
}

#[cfg(feature = "aws")]
pub mod aws;
#[cfg(feature = "digital-ocean")]
pub mod digital_ocean;
#[cfg(feature = "ipify")]
pub mod ipify;

#[cfg(feature = "aws")]
pub use aws::*;
#[cfg(feature = "digital-ocean")]
pub use digital_ocean::*;
#[cfg(feature = "ipify")]
pub use ipify::*;