Skip to main content

format

Function format 

Source
pub fn format(content_type: &ContentType) -> Result<String, FormatError>
Expand description

Format a ContentType into a header string, validating the type and parameters.

Returns a FormatError for an invalid media type, parameter name, or value.

use content_type::ContentType;
let ct = ContentType::new("text/plain").with_parameter("name", "two words");
assert_eq!(content_type::format(&ct).unwrap(), "text/plain; name=\"two words\"");

ยงErrors

Returns FormatError if type_ is not a valid type/subtype, a parameter name is not a token, or a value cannot be encoded.