From 24a48fbc89c4aedbd3b1a7fd785e0e9c226174ba Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Sat, 14 Oct 2017 00:07:21 -0400 Subject: Regenerate documentation for 0.6.0 --- target/doc/mailparse/fn.parse_content_type.html | 26 ++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'target/doc/mailparse/fn.parse_content_type.html') diff --git a/target/doc/mailparse/fn.parse_content_type.html b/target/doc/mailparse/fn.parse_content_type.html index f374f48..a6e1511 100644 --- a/target/doc/mailparse/fn.parse_content_type.html +++ b/target/doc/mailparse/fn.parse_content_type.html @@ -48,10 +48,12 @@ [] - [src] -
pub fn parse_content_type(
    header: &str
) -> Result<ParsedContentType, MailParseError>

Helper method to parse a header value as a Content-Type header. The charset -defaults to "us-ascii" if no charset parameter is provided in the header -value.

+ [src] +
pub fn parse_content_type(header: &str) -> ParsedContentType

Helper method to parse a header value as a Content-Type header. Note that +the returned object's params map will contain a charset key if a charset +was explicitly specified in the header; otherwise the params map will not +contain a charset key. Regardless, the charset field will contain a +charset - either the one explicitly specified or the default of "us-ascii".

Examples

@@ -59,27 +61,29 @@ value.

let (parsed, _) = parse_header( b"Content-Type: text/html; charset=foo; boundary=\"quotes_are_removed\"") .unwrap(); - let ctype = parse_content_type(&parsed.get_value().unwrap()).unwrap(); + let ctype = parse_content_type(&parsed.get_value().unwrap()); assert_eq!(ctype.mimetype, "text/html"); assert_eq!(ctype.charset, "foo"); - assert_eq!(ctype.boundary, Some("quotes_are_removed".to_string()));
+ assert_eq!(ctype.params.get("boundary"), Some(&"quotes_are_removed".to_string())); + assert_eq!(ctype.params.get("charset"), Some(&"foo".to_string()));
 use mailparse::{parse_header, parse_content_type};
     let (parsed, _) = parse_header(b"Content-Type: bogus").unwrap();
-    let ctype = parse_content_type(&parsed.get_value().unwrap()).unwrap();
+    let ctype = parse_content_type(&parsed.get_value().unwrap());
     assert_eq!(ctype.mimetype, "bogus");
     assert_eq!(ctype.charset, "us-ascii");
-    assert_eq!(ctype.boundary, None);
+ assert_eq!(ctype.params.get("boundary"), None); + assert_eq!(ctype.params.get("charset"), None);
 use mailparse::{parse_header, parse_content_type};
     let (parsed, _) = parse_header(br#"Content-Type: application/octet-stream;name="=?utf8?B?6L+O5ai255m95a+M576O?=";charset="utf8""#).unwrap();
-    let ctype = parse_content_type(&parsed.get_value().unwrap()).unwrap();
+    let ctype = parse_content_type(&parsed.get_value().unwrap());
     assert_eq!(ctype.mimetype, "application/octet-stream");
     assert_eq!(ctype.charset, "utf8");
-    assert_eq!(ctype.boundary, None);
-    assert_eq!(ctype.name, Some("迎娶白富美".to_string()));
+ assert_eq!(ctype.params.get("boundary"), None); + assert_eq!(ctype.params.get("name"), Some(&"迎娶白富美".to_string()));
-- cgit v1.2.3