Struct magic::Cookie
[−]
[src]
pub struct Cookie { /* fields omitted */ }
Configuration of which CookieFlags
and magic databases to use
Methods
impl Cookie
[src]
fn file<P: AsRef<Path>>(&self, filename: P) -> Result<String, MagicError>
Returns a textual description of the contents of the filename
fn buffer(&self, buffer: &[u8]) -> Result<String, MagicError>
Returns a textual description of the contents of the buffer
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 MagicError
in
the Result
returned by the other functions.
fn set_flags(&self, flags: CookieFlags) -> bool
Sets the flags to use
Overwrites any previously set flags, e.g. those from load()
.
fn check<P: AsRef<Path>>(&self, filenames: &[P]) -> Result<(), MagicError>
Check the validity of entries in the database filenames
fn compile<P: AsRef<Path>>(&self, filenames: &[P]) -> Result<(), MagicError>
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.
fn list<P: AsRef<Path>>(&self, filenames: &[P]) -> Result<(), MagicError>
Dumps all magic entries in the given database filenames
in a human readable format
fn load<P: AsRef<Path>>(&self, filenames: &[P]) -> Result<(), MagicError>
Loads the given database filenames
for further queries
Adds '.mgc' to the database filenames as appropriate.
fn open(flags: CookieFlags) -> Result<Cookie, MagicError>
Creates a new configuration, flags
specify how other functions should behave
This does not load()
any databases yet.
Trait Implementations
impl Drop for Cookie
[src]
fn drop(&mut self)
Closes the magic database and deallocates any resources used