#![doc = include_str!("readme.md")]
use http::{Method, Uri, Version, header::HeaderMap};
use std::fmt;
#[derive(Debug)]
pub enum ExtractorError {
PathRejection(String),
QueryRejection(String),
JsonRejection(String),
FormRejection(String),
ExtensionRejection(String),
HostRejection(String),
TypedHeaderRejection(String),
CookieRejection(String),
MultipartRejection(String),
WebSocketUpgradeRejection(String),
BytesRejection(String),
StreamRejection(String),
Custom(String),
}
impl fmt::Display for ExtractorError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ExtractorError::PathRejection(e) => write!(f, "Path extraction failed: {}", e),
ExtractorError::QueryRejection(e) => write!(f, "Query extraction failed: {}", e),
ExtractorError::JsonRejection(e) => write!(f, "Json extraction failed: {}", e),
ExtractorError::FormRejection(e) => write!(f, "Form extraction failed: {}", e),
ExtractorError::ExtensionRejection(e) => write!(f, "Extension extraction failed: {}", e),
ExtractorError::HostRejection(e) => write!(f, "Host extraction failed: {}", e),
ExtractorError::TypedHeaderRejection(e) => write!(f, "TypedHeader extraction failed: {}", e),
ExtractorError::CookieRejection(e) => write!(f, "Cookie extraction failed: {}", e),
ExtractorError::MultipartRejection(e) => write!(f, "Multipart extraction failed: {}", e),
ExtractorError::WebSocketUpgradeRejection(e) => write!(f, "WebSocketUpgrade extraction failed: {}", e),
ExtractorError::BytesRejection(e) => write!(f, "Bytes extraction failed: {}", e),
ExtractorError::StreamRejection(e) => write!(f, "Stream extraction failed: {}", e),
ExtractorError::Custom(msg) => write!(f, "Extractor error: {}", msg),
}
}
}
impl std::error::Error for ExtractorError {}
#[derive(Debug, Clone)]
pub struct Header<T>(pub T);
pub type HttpMethod = Method;
pub type RequestUri = Uri;
pub type HttpVersion = Version;
pub type Headers = HeaderMap;
#[derive(Debug, Clone)]
pub struct Extension<T>(pub T);
#[derive(Debug, Clone, serde::Deserialize)]
pub struct Form<T>(pub T);
#[derive(Debug, Clone, serde::Deserialize)]
pub struct Json<T>(pub T);
#[derive(Debug, Clone)]
pub struct Multipart;
pub type OriginalUri = http::Uri;
#[derive(Debug, Clone)]
pub struct Path<T>(pub T);
#[derive(Debug, Clone, serde::Deserialize)]
pub struct Query<T>(pub T);
#[derive(Debug, Clone)]
pub struct State<T>(pub T);
#[derive(Debug, Clone)]
pub struct WebSocketUpgrade;
pub use bytes::Bytes;
pub type Stream = crate::Body;