pub struct Magic { /* private fields */ }
Expand description
Configuration of which Flags
and magic databases to use
Implementations§
Source§impl Magic
impl Magic
Sourcepub fn error(&self) -> Option<String>
pub fn error(&self) -> Option<String>
Returns a textual explanation of the last error, if any
You should not need to call this, since you can use the FileMagicError
in
the Result
returned by the other functions.
Sourcepub fn file<P: AsRef<Path>>(
&self,
filename: P,
) -> Result<String, FileMagicError>
pub fn file<P: AsRef<Path>>( &self, filename: P, ) -> Result<String, FileMagicError>
Returns a textual description of the contents of the filename
Sourcepub fn buffer(&self, buffer: &[u8]) -> Result<String, FileMagicError>
pub fn buffer(&self, buffer: &[u8]) -> Result<String, FileMagicError>
Returns a textual description of the contents of the buffer
Sourcepub fn check<P: AsRef<Path>>(
&self,
filenames: &[P],
) -> Result<(), FileMagicError>
pub fn check<P: AsRef<Path>>( &self, filenames: &[P], ) -> Result<(), FileMagicError>
Check the validity of entries in the database filenames
Sourcepub fn compile<P: AsRef<Path>>(
&self,
filenames: &[P],
) -> Result<(), FileMagicError>
pub fn compile<P: AsRef<Path>>( &self, filenames: &[P], ) -> Result<(), FileMagicError>
Compiles the given database filenames
for faster access
The compiled files created are named from the basename
of each file argument with ‘.mgc’ appended to it.
Sourcepub fn list<P: AsRef<Path>>(
&self,
filenames: &[P],
) -> Result<(), FileMagicError>
pub fn list<P: AsRef<Path>>( &self, filenames: &[P], ) -> Result<(), FileMagicError>
Dumps all magic entries in the given database filenames
in a human readable format
Sourcepub fn set_flags(&self, flags: Flags) -> bool
pub fn set_flags(&self, flags: Flags) -> bool
Sets the flags to use
Overwrites any previously set flags, e.g. those from load()
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Magic
impl RefUnwindSafe for Magic
impl !Send for Magic
impl !Sync for Magic
impl Unpin for Magic
impl UnwindSafe for Magic
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more