-
Perhaps I'm doing something stupid, but this code doesn't compile: async fn get_content_type(path: &Path) -> Result<String> {
let cookie = magic::Cookie::open(
magic::cookie::Flags::ERROR |
magic::cookie::Flags::MIME_ENCODING |
magic::cookie::Flags::MIME_TYPE
)?.load(
&Default::default()
)?;
Ok(cookie.file(path)?)
} Among other things, it complains:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Upon first look, this is a variation of robo9k/rust-magic-sys#28 You could map this to your own error and thus discard the private |
Beta Was this translation helpful? Give feedback.
-
Thanks for the answer. It helped a lot. For anyone who finds this discussion (including myself), what I did to fix it was I changed the |
Beta Was this translation helpful? Give feedback.
Upon first look, this is a variation of robo9k/rust-magic-sys#28
The problem being that
LoadError<>
contains the originalCookie<>
so you can recover it, but this is a raw pointer fromlibmagic
without enough guarantees to make itSend
norSync
.You could map this to your own error and thus discard the private
!Sync
field.Currently
LoadError
doesn't expose much beyondstd:error::Error
, so if you actually need access to its internals, let me know.