pub trait ApiResponse: Sized {
const BAD_REQUEST_HANDLER: bool = false;
// Required methods
fn meta() -> MetaResponses;
fn register(registry: &mut Registry);
// Provided method
fn from_parse_request_error(err: Error) -> Self { ... }
}
Expand description
Represents an OpenAPI responses object.
§Provided Implementations
-
Binary<T: Type>
A binary response with content type
application/octet-stream
. -
Json<T: Type>
A JSON response with content type
application/json
. -
PlainText<T: Type>
A utf8 string response with content type
text/plain
. -
Attachment<T: Type>
A file download response, the content type is
application/octet-stream
. -
Response<T: Type>
A response type use it to modify the status code and HTTP headers.
-
()
It means that this API does not have any response body.
-
poem::Result<T: ApiResponse>
It means that an error may occur in this API.
-
Any type derived from the
ApiResponse
macroA complex response derived from the
ApiResponse
macro.
Provided Associated Constants§
Sourceconst BAD_REQUEST_HANDLER: bool = false
const BAD_REQUEST_HANDLER: bool = false
If true, it means that the response object has a custom bad request handler.
Required Methods§
Provided Methods§
Sourcefn from_parse_request_error(err: Error) -> Self
fn from_parse_request_error(err: Error) -> Self
Convert poem::Error
to this response object.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.