libmagic
bindings for the Rust programming language.
libmagic
recognizes the type of data contained in a file (or buffer) and can give you
a textual description, a MIME type and the usual file extensions.
This project's crate is
published on the crates.io
Rust package registry: the magic
crate
In your Rust project, use cargo add
to specify dependencies:
$ cargo add magic
To install the latest in-development version instead:
$ cargo add --git https://github.com/robo9k/rust-magic
You might be familiar with libmagic
's CLI; file
:
$ file data/tests/rust-logo-128x128-blk.png
data/tests/rust-logo-128x128-blk.png: PNG image data, 128 x 128, 8-bit/color RGBA, non-interlaced
You can implement something similar in Rust with the magic
crate, see crate README:
$ cargo run --example file-ish -- data/tests/rust-logo-128x128-blk.png
PNG image data, 128 x 128, 8-bit/color RGBA, non-interlaced
For more details, check the magic
rustdoc: robo9k.github.io/rust-magic/magic
For the magic
crate requirements, see crate README.
For developing the rust-magic
project, see CONTRIBUTING.
This project is licensed under either of
at your option.
For further details, see LICENSE.
See SECURITY.
See CONTRIBUTING.