#![deny(clippy::all, missing_docs)]
#![forbid(unsafe_code)]
use std::collections::HashMap;
#[cfg(feature = "server")]
#[macro_use] extern crate log;
#[cfg(feature = "json")]
use serde_json::Value;
#[macro_use] mod macros;
mod error;
mod body;
#[cfg(feature = "multipart")] mod multipart;
mod stream;
#[cfg(feature = "client")] mod client;
#[cfg(feature = "server")] mod server;
pub use error::*;
#[cfg(feature = "multipart")] pub use multipart::*;
#[cfg(feature = "client")] pub use client::*;
#[cfg(feature = "server")] pub use server::*;
#[derive(Debug, Clone, PartialEq)]
pub enum StatusInfo {
Response(i32, String), Request(String, String), }
#[derive(Debug, Clone, PartialEq)]
pub struct GeneralInfo {
pub status: StatusInfo,
pub headers: HashMap<String, String>,
}
#[cfg(feature = "json")]
impl GeneralInfo {
pub fn json(&self) -> Value {
match &self.status {
StatusInfo::Response(code, reason) => {
serde_json::json!({
"status": {
"code": code,
"reason": reason
},
"headers": self.headers
})
},
StatusInfo::Request(method, resource) => {
serde_json::json!({
"status": {
"method": method,
"resource": resource
},
"headers": self.headers
})
},
}
}
}