poem_openapi/payload/
mod.rsmod attachment;
mod base64_payload;
mod binary;
mod event_stream;
mod form;
mod html;
mod json;
mod plain_text;
mod response;
mod xml;
mod yaml;
use std::future::Future;
use poem::{Request, RequestBody, Result};
pub use self::{
attachment::{Attachment, AttachmentType},
base64_payload::Base64,
binary::Binary,
event_stream::EventStream,
form::Form,
html::Html,
json::Json,
plain_text::PlainText,
response::Response,
xml::Xml,
yaml::Yaml,
};
use crate::registry::{MetaSchemaRef, Registry};
pub trait Payload: Send {
const CONTENT_TYPE: &'static str;
fn check_content_type(content_type: &str) -> bool {
content_type == Self::CONTENT_TYPE
}
fn schema_ref() -> MetaSchemaRef;
#[allow(unused_variables)]
fn register(registry: &mut Registry) {}
}
pub trait ParsePayload: Sized {
const IS_REQUIRED: bool;
fn from_request(
request: &Request,
body: &mut RequestBody,
) -> impl Future<Output = Result<Self>> + Send;
}