pub enum Body {
Json(Value),
Form(DashMap<String, String>),
Bytes(Bytes),
}Expand description
The body of an HTTP request.
Body encapsulates the different types of request bodies that can be sent
with an HTTP request. It supports JSON payloads, form data, and raw bytes.
§Variants
Json: A JSON value (typically an object or array)Form: Key-value form data encoded asapplication/x-www-form-urlencodedBytes: Raw binary data
§Example
use spider_util::request::Body;
use serde_json::json;
use dashmap::DashMap;
use bytes::Bytes;
// JSON body
let json_body = Body::Json(json!({"name": "test"}));
// Form data
let mut form = DashMap::new();
form.insert("key".to_string(), "value".to_string());
let form_body = Body::Form(form);
// Raw bytes
let bytes_body = Body::Bytes(Bytes::from("raw data"));Variants§
Json(Value)
JSON payload.
Form(DashMap<String, String>)
Form data (key-value pairs).
Bytes(Bytes)
Raw binary data.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Body
impl<'de> Deserialize<'de> for Body
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl !Freeze for Body
impl !RefUnwindSafe for Body
impl Send for Body
impl Sync for Body
impl Unpin for Body
impl UnsafeUnpin for Body
impl UnwindSafe for Body
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more