mime2ext

Function mime2ext

Source
pub fn mime2ext<S: AsRef<str>>(mimetype: S) -> Option<&'static str>
Expand description

Given a mimetype, pick a suitable file extension.

ยงExample

use mime2ext::mime2ext;

assert_eq!(mime2ext("image/png"), Some("png"));
assert_eq!(mime2ext("application/octet-stream"), Some("bin"));
assert_eq!(mime2ext("text/html; charset=UTF-8"), Some("html"));
assert_eq!(mime2ext("notareal/mimetype"), None);
assert_eq!(mime2ext("invalid-mimetype"), None);