Skip to main content

Module content_type

Module content_type 

Source
Expand description

Media type / Content-Type representation.

ContentType models a structured Content-Type header value consisting of a type/subtype pair and optional parameters (e.g. charset=utf-8).

Pre-built constants cover the most common media types.

§Example

use api_bones::content_type::ContentType;

let ct = ContentType::application_json();
assert_eq!(ct.to_string(), "application/json");

let with_charset = ContentType::text_plain_utf8();
assert_eq!(with_charset.to_string(), "text/plain; charset=utf-8");

let parsed: ContentType = "application/json".parse().unwrap();
assert_eq!(parsed, ContentType::application_json());

Structs§

ContentType
A structured Content-Type / media type value.
ParseContentTypeError
Error returned when parsing a ContentType fails.