hevy 0.1.0

An async Rust client library for the Hevy public API (https://api.hevyapp.com/docs/)
Documentation
use thiserror::Error;

/// The result type returned by all fallible operations in this crate.
pub type Result<T> = std::result::Result<T, HevyError>;

/// Errors that can occur while interacting with the Hevy API.
#[derive(Debug, Error)]
pub enum HevyError {
    /// The underlying HTTP request failed (connection error, timeout, etc.).
    #[error("request failed: {0}")]
    Request(#[from] reqwest::Error),

    /// The response body could not be deserialized into the expected type.
    #[error("failed to decode response body: {0}")]
    Decode(serde_json::Error),

    /// The API returned a non-success status code.
    ///
    /// `message` contains the `error` field from the response body when present,
    /// otherwise the raw response body (if any).
    #[error("Hevy API returned {status}: {message}")]
    Api {
        /// The HTTP status code returned by the API.
        status: u16,
        /// A human readable error message extracted from the response, if any.
        message: String,
    },

    /// The client was misused, e.g. an invalid base URL was supplied.
    #[error("invalid client configuration: {0}")]
    Config(String),
}