product-os-request 0.0.55

Product OS : Request provides a fully featured HTTP request library combining elements of reqwest and hyper for async requests with a series of helper methods to allow for easier usage depending upon your needs for one-time or repeat usage.
Documentation
//! Error types for ProductOS Request
//!
//! This module provides error types used throughout the library.

use alloc::string::String;

/// Error type for ProductOS Request operations
///
/// Represents errors that can occur during HTTP request operations.
#[cfg(any(feature = "request", feature = "request_std"))]
#[derive(Debug)]
pub enum ProductOSRequestError {
    /// An error occurred with the given message
    Error(String),
    /// Invalid URI provided
    InvalidUri(String),
    /// Request timed out
    Timeout(String),
    /// TLS/certificate error
    Tls(String),
    /// Response body could not be read or parsed
    BodyError(String),
    /// No error occurred
    ///
    /// # Deprecated
    ///
    /// This variant is an anti-pattern. Use `Result::Ok` instead of wrapping
    /// a non-error in an error type. This will be removed in a future version.
    #[deprecated(
        since = "0.0.54",
        note = "Use Result::Ok instead of ProductOSRequestError::None"
    )]
    None,
}

#[cfg(any(feature = "request", feature = "request_std"))]
impl core::fmt::Display for ProductOSRequestError {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        #[allow(deprecated)]
        match &self {
            ProductOSRequestError::Error(m) => write!(f, "{}", m),
            ProductOSRequestError::InvalidUri(m) => write!(f, "Invalid URI: {}", m),
            ProductOSRequestError::Timeout(m) => write!(f, "Request timeout: {}", m),
            ProductOSRequestError::Tls(m) => write!(f, "TLS error: {}", m),
            ProductOSRequestError::BodyError(m) => write!(f, "Body error: {}", m),
            ProductOSRequestError::None => write!(f, "No error"),
        }
    }
}

#[cfg(any(feature = "std_base", feature = "std_reqwest", feature = "std_hyper"))]
impl std::error::Error for ProductOSRequestError {}