Crates.io | fmedia |
lib.rs | fmedia |
version | 0.2.0 |
source | src |
created_at | 2021-07-31 14:58:09.926551 |
updated_at | 2021-07-31 15:20:30.586479 |
description | Get file media type or suffix |
homepage | |
repository | |
max_upload_size | |
id | 429708 |
size | 49,646 |
use fmedia::MediaType;
assert_eq!("image/png", MediaType::from_file_extension("png").unwrap());
assert_eq!(
"image/jpeg",
MediaType::from_file_extension("jpeg").unwrap()
);
assert_eq!(
"image/svg+xml",
MediaType::from_file_extension("svg").unwrap()
);
assert_eq!(
"application/json",
MediaType::from_file_extension("json").unwrap()
);
Return one or more results
use fmedia::FileExtension;
assert_eq!(
vec!["png"],
FileExtension::from_media_type("image/png").unwrap()
);
assert_eq!(
vec!["jpe", "jpeg", "jpg"],
FileExtension::from_media_type("image/jpeg").unwrap()
);
assert_eq!(
vec!["svg", "svgz"],
FileExtension::from_media_type("image/svg+xml").unwrap()
);
assert_eq!(
vec!["json"],
FileExtension::from_media_type("application/json").unwrap()
);