qubit_http/request/http_request_body.rs
1/*******************************************************************************
2 *
3 * Copyright (c) 2025 - 2026 Haixing Hu.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Licensed under the Apache License, Version 2.0.
8 *
9 ******************************************************************************/
10//! Request body variants.
11
12use bytes::Bytes;
13use serde::{Deserialize, Serialize};
14use strum::{Display, EnumString};
15
16/// Encodes how the outbound body is represented before sending via reqwest.
17#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, Display, EnumString)]
18#[serde(rename_all = "snake_case")]
19#[strum(serialize_all = "snake_case")]
20pub enum HttpRequestBody {
21 /// No body (typical for GET/HEAD).
22 #[default]
23 Empty,
24 /// Opaque binary payload.
25 #[strum(disabled)]
26 Bytes(Bytes),
27 /// UTF-8 text; builders may set `Content-Type: text/plain`.
28 #[strum(disabled)]
29 Text(String),
30 /// JSON-serialized bytes; builders may set `Content-Type: application/json`.
31 #[strum(disabled)]
32 Json(Bytes),
33 /// URL-encoded form bytes; builders may set `Content-Type: application/x-www-form-urlencoded`.
34 #[strum(disabled)]
35 Form(Bytes),
36 /// Multipart body bytes; builders may set `Content-Type: multipart/form-data; boundary=...`.
37 #[strum(disabled)]
38 Multipart(Bytes),
39 /// NDJSON bytes (`\n`-delimited JSON objects); builders may set `application/x-ndjson`.
40 #[strum(disabled)]
41 Ndjson(Bytes),
42 /// Chunked upload payload represented as ordered byte chunks.
43 ///
44 /// The client sends this variant through reqwest streaming body support.
45 #[strum(disabled)]
46 Stream(Vec<Bytes>),
47}