technitium 0.4.0

Typed async Rust client for the Technitium DNS Server API
Documentation
#![allow(dead_code)]
use technitium::Client;

/// Read the Technitium server URL from the environment.
///
/// Falls back to `http://localhost:5380` if `TECHNITIUM_URL` is not set.
pub fn server_url() -> String {
    std::env::var("TECHNITIUM_URL").unwrap_or_else(|_| "http://localhost:5380".to_string())
}

/// Read the admin username from the environment.
pub fn admin_username() -> String {
    std::env::var("TECHNITIUM_USER").unwrap_or_else(|_| "admin".to_string())
}

/// Read the admin password from the environment.
pub fn admin_password() -> String {
    std::env::var("TECHNITIUM_PASSWORD").unwrap_or_else(|_| "admin".to_string())
}

/// Build an unauthenticated client pointing at the test server.
pub fn build_client() -> Client {
    Client::builder()
        .base_url(server_url())
        .build()
        .expect("failed to build test client")
}

/// Build an authenticated client by logging in with admin credentials.
pub async fn authenticated_client() -> Client {
    let client = build_client();
    client
        .login(&admin_username(), &admin_password())
        .await
        .expect("failed to authenticate test client");
    client
}