//! The library provides integration with the limon service.

#![warn(missing_docs)]
#![forbid(unsafe_code)]

#[cfg(feature = "metrics")]
pub mod metrics;

/// Configuration settings for the client.
#[derive(Clone)]
pub struct Config {
  /// The debug mode displays more information about the library.
  pub debug: bool,

  /// Configuration of the metrics management module.
  #[cfg(feature = "metrics")]
  pub metrics: Option<metrics::MetricsConfig>,
}

impl Default for Config {
  fn default() -> Self {
    Config {
      debug: cfg!(debug_assertions),

      #[cfg(feature = "metrics")]
      metrics: Some(metrics::MetricsConfig::default()),
    }
  }
}

#[allow(dead_code)]
pub(crate) struct Client {
  token: String,
  config: Config,
}

/// Creates the `limon` client with a given config.
///
/// # Example
/// ```rust
/// fn main() {
///   limon::init(limon::Config {
///     debug: true,
///     ..Default::default()
///   });
///
///   // Your application...
/// }
/// ```
pub fn init(token: impl Into<String>, config: Config) {
  let _client = Client { token: token.into(), config: config.clone() };

  #[cfg(feature = "metrics")]
  metrics::MetricsSdk::init(config.metrics.unwrap_or_default());
}
