[][src]Struct filemagic::Magic

pub struct Magic { /* fields omitted */ }

Configuration of which Flags and magic databases to use

Implementations

impl Magic[src]

pub fn error(&self) -> Option<String>[src]

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.

pub fn file<P: AsRef<Path>>(
    &self,
    filename: P
) -> Result<String, FileMagicError>
[src]

Returns a textual description of the contents of the filename

pub fn buffer(&self, buffer: &[u8]) -> Result<String, FileMagicError>[src]

Returns a textual description of the contents of the buffer

pub fn check<P: AsRef<Path>>(
    &self,
    filenames: &[P]
) -> Result<(), FileMagicError>
[src]

Check the validity of entries in the database filenames

pub fn compile<P: AsRef<Path>>(
    &self,
    filenames: &[P]
) -> Result<(), FileMagicError>
[src]

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.

pub fn list<P: AsRef<Path>>(
    &self,
    filenames: &[P]
) -> Result<(), FileMagicError>
[src]

Dumps all magic entries in the given database filenames in a human readable format

pub fn set_flags(&self, flags: Flags) -> bool[src]

Sets the flags to use

Overwrites any previously set flags, e.g. those from load().

pub fn open(flags: Flags) -> Result<Magic, FileMagicError>[src]

Creates a new configuration, flags specify how other functions should behave

This does not load() any databases yet.

pub fn load<P: AsRef<Path>>(
    &self,
    magic_databases: &[P]
) -> Result<(), FileMagicError>
[src]

Loads the given database filenames for further queries

Adds '.mgc' to the database files as appropriate.

Trait Implementations

impl Drop for Magic[src]

pub fn drop(&mut self)[src]

Closes the magic database and deallocates any resources used

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.