#![cfg_attr(feature = "async", doc = include_str!("../README.md"))]
#![cfg_attr(
not(feature = "async"),
doc = "Unofficial client for the Provident (MeterConnex) utility metering portal (blocking API)."
)]
#![warn(missing_docs)]
#[cfg(all(feature = "async", feature = "blocking"))]
compile_error!(
"features `async` and `blocking` are mutually exclusive; use `default-features = false` with `blocking`"
);
#[cfg(not(any(feature = "async", feature = "blocking")))]
compile_error!("enable exactly one of the `async` or `blocking` features");
pub mod account;
pub mod auth;
mod error;
pub mod http;
pub mod models;
pub mod rates;
pub mod usage;
pub use error::{Error, Result};
pub use http::ClientConfig;
#[derive(Debug, Clone)]
pub struct Client {
pub auth: auth::Auth,
pub account: account::Account,
pub usage: usage::Usage,
pub rates: rates::Rates,
}
impl Client {
pub fn new() -> Result<Self> {
Self::with_config(ClientConfig::default())
}
pub fn with_config(config: ClientConfig) -> Result<Self> {
let http = http::Client::new(config)?;
Ok(Self {
auth: auth::Auth::new(http.clone()),
account: account::Account::new(http.clone()),
usage: usage::Usage::new(http.clone()),
rates: rates::Rates::new(http),
})
}
}