Skip to main content

qubit_http/options/
http_config_error_kind.rs

1/*******************************************************************************
2 *
3 *    Copyright (c) 2025 - 2026.
4 *    Haixing Hu, Qubit Co. Ltd.
5 *
6 *    All rights reserved.
7 *
8 ******************************************************************************/
9//! # HTTP configuration error kind
10//!
11//! Category enum for [`crate::HttpConfigError`].
12//!
13//! # Author
14//!
15//! Haixing Hu
16
17use parse_display::{Display, FromStr as DeriveFromStr};
18use serde::{Deserialize, Serialize};
19
20/// Category of HTTP configuration errors.
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Display, DeriveFromStr)]
22#[serde(rename_all = "snake_case")]
23#[display(style = "snake_case")]
24pub enum HttpConfigErrorKind {
25    /// A required configuration key is missing.
26    #[display("missing field")]
27    #[from_str(regex = "(?i)missing\\s+field")]
28    MissingField,
29    /// The value exists but cannot be converted to the expected type.
30    #[display("type error")]
31    #[from_str(regex = "(?i)type\\s+error")]
32    TypeError,
33    /// The value is present and well-typed but semantically invalid.
34    #[display("invalid value")]
35    #[from_str(regex = "(?i)invalid\\s+value")]
36    InvalidValue,
37    /// A header name or value cannot be converted to an HTTP header.
38    #[display("invalid header")]
39    #[from_str(regex = "(?i)invalid\\s+header")]
40    InvalidHeader,
41    /// An underlying `qubit-config` error occurred.
42    #[display("config error")]
43    #[from_str(regex = "(?i)config\\s+error")]
44    ConfigError,
45}