pub struct MagicDb { /* private fields */ }Expand description
Represents a database of MagicRule
Implementations§
Source§impl MagicDb
impl MagicDb
Sourcepub fn load(&mut self, mf: MagicSource) -> Result<&mut Self, Error>
pub fn load(&mut self, mf: MagicSource) -> Result<&mut Self, Error>
Loads rules from a MagicSource
§Arguments
mf- TheMagicSourceto load rules from
§Returns
Result<&mut Self, Error>- Self for chaining or an error
Sourcepub fn first_magic<R: Read + Seek>(
&self,
r: &mut R,
extension: Option<&str>,
) -> Result<Magic<'_>, Error>
pub fn first_magic<R: Read + Seek>( &self, r: &mut R, extension: Option<&str>, ) -> Result<Magic<'_>, Error>
Detects file Magic stopping at the first matching magic. Magic
rules are evaluated from the best to the least relevant, so this method
returns most of the time the best magic. For the rare cases where
it doesn’t or if the best result is always required, use MagicDb::best_magic
§Arguments
r- A readable and seekable inputextension- Optional file extension to use for acceleration
§Returns
Result<Magic<'_>, Error>- The detection result or an error
Trait Implementations§
Source§impl<'de> Deserialize<'de> for MagicDb
impl<'de> Deserialize<'de> for MagicDb
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for MagicDb
impl RefUnwindSafe for MagicDb
impl Send for MagicDb
impl Sync for MagicDb
impl Unpin for MagicDb
impl UnwindSafe for MagicDb
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