We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It takes a bit of boilerplate to convert /foo/img.png to MIME image/png:
/foo/img.png
image/png
pub fn get_mime(src: &str) -> String { let ext = Path::new(src) .extension() .and_then(OsStr::to_str) .unwrap_or(""); let mime_type = mime_guess::get_mime_type(&ext); format!("{}/{}", mime_type.type_(), mime_type.subtype()) }
It'd be nice if there was a convenience method built-in that would so something similar to the above.
Thanks!
The text was updated successfully, but these errors were encountered:
I think #38 will cover this, I just keep forgetting to merge it.
Sorry, something went wrong.
I figured it out:
let icon_type = mime_guess::guess_mime_type(&src).to_string();
What tripped me up here is that .to_string() didn't show up in the docs at all, so I didn't know it was available. Thanks for the quick reply tho!
.to_string()
That's because Mime implements Display and ToString is implemented for all implementors of that.
Mime
Display
ToString
However, the strings are available already so you don't have to round-trip like that. It just needs a function exposing them.
No branches or pull requests
It takes a bit of boilerplate to convert
/foo/img.png
to MIMEimage/png
:It'd be nice if there was a convenience method built-in that would so something similar to the above.
Thanks!
The text was updated successfully, but these errors were encountered: