poem_openapi/payload/
mod.rs1mod attachment;
4mod base64_payload;
5mod binary;
6mod event_stream;
7mod form;
8mod html;
9mod json;
10mod plain_text;
11mod response;
12mod xml;
13mod yaml;
14
15use std::future::Future;
16
17use poem::{Request, RequestBody, Result};
18
19pub use self::{
20 attachment::{Attachment, AttachmentType},
21 base64_payload::Base64,
22 binary::Binary,
23 event_stream::EventStream,
24 form::Form,
25 html::Html,
26 json::Json,
27 plain_text::PlainText,
28 response::Response,
29 xml::Xml,
30 yaml::Yaml,
31};
32use crate::registry::{MetaSchemaRef, Registry};
33
34pub trait Payload: Send {
36 const CONTENT_TYPE: &'static str;
38
39 fn check_content_type(content_type: &str) -> bool {
41 content_type == Self::CONTENT_TYPE
42 }
43
44 fn schema_ref() -> MetaSchemaRef;
46
47 #[allow(unused_variables)]
49 fn register(registry: &mut Registry) {}
50}
51
52pub trait ParsePayload: Sized {
54 const IS_REQUIRED: bool;
56
57 fn from_request(
59 request: &Request,
60 body: &mut RequestBody,
61 ) -> impl Future<Output = Result<Self>> + Send;
62}