pub struct MediaType {
pub name: &'static str,
pub json_compatible: bool,
pub func: fn(bytes: &[u8], deserialize: bool) -> Result<Option<Value>, Box<dyn Error>>,
}
Expand description
Defines Mediatype for contentMediaType
.
Fields§
§name: &'static str
Name of this media-type as defined in RFC 2046.
Example: application/json
json_compatible: bool
whether this media type can be deserialized to json. If so it can
be validated by contentSchema
keyword.
func: fn(bytes: &[u8], deserialize: bool) -> Result<Option<Value>, Box<dyn Error>>
Check whether bytes
conforms to this media-type.
Should return Ok(Some(Value))
if deserialize
is true
, otherwise it can return Ok(None)
.
Ideally you could deserialize to serde::de::IgnoredAny
if deserialize
is false
to gain
some performance.
deserialize
is always false
if json_compatible
is false
.