pub trait RequestBody: ResourceType + FromBody {
    fn supported_types() -> Option<Vec<Mime>> { ... }
}
Expand description

A type that can be used inside a request body. Implemented for every type that is deserializable with serde. If the openapi feature is used, it must also be of type OpenapiType.

If you want a non-deserializable type to be used as a request body, e.g. because you’d like to get the raw data, you can derive it for your own type. All you need is to have a type implementing FromBody and optionally a list of supported media types:

#[derive(FromBody, RequestBody)]
#[supported_types(mime::IMAGE_GIF, mime::IMAGE_JPEG, mime::IMAGE_PNG)]
struct RawImage {
	content: Vec<u8>,
	content_type: Mime
}

Provided Methods

Return all types that are supported as content types. Use None if all types are supported.

Implementors