qubit_http/sse/sse_json_mode.rs
1/*******************************************************************************
2 *
3 * Copyright (c) 2025 - 2026.
4 * Haixing Hu, Qubit Co. Ltd.
5 *
6 * All rights reserved.
7 *
8 ******************************************************************************/
9//! Strictness for JSON parsing on SSE `data:` lines.
10//!
11//! # Author
12//!
13//! Haixing Hu
14
15use parse_display::FromStr as DeriveFromStr;
16use serde::{Deserialize, Serialize};
17
18/// How to handle JSON parse failures on SSE `data:` lines.
19#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, DeriveFromStr)]
20#[serde(rename_all = "snake_case")]
21#[display(style = "snake_case")]
22pub enum SseJsonMode {
23 /// Skip bad chunks and continue.
24 #[from_str(regex = "(?i)lenient")]
25 Lenient,
26 /// Propagate [`crate::HttpError::sse_decode`] on first failure.
27 #[from_str(regex = "(?i)strict")]
28 Strict,
29}