[−][src]Crate filemagic
This crate provides bindings for libmagic
, which recognizes the
type of data contained in a file (or buffer).
You should be already familiar with libmagic
's CLI command file
:
$ file rust-logo-128x128-blk.png
rust-logo-128x128-blk.png: PNG image data, 128 x 128, 8-bit/color RGBA, non-interlaced
Usage example
Here's an example of using this crate:
use filemagic::Magic; fn main() { let test_file = "path/to/file"; let cookie = Magic::open(Default::default()).expect("error"); cookie.load::<String>(&[]).expect("error"); let magic = cookie.file(&test_file).expect("error in magic"); println!("magic= {}", magic); }
Re-exports
pub use version::version; |
pub use flags::Flags; |
Modules
flags | |
macros | |
version |
Macros
magic | Returns the Mime type of a file |
Structs
FileMagicError | The error type used in this crate |
Magic | Configuration of which |