pub struct MimeDB { /* private fields */ }
Expand description
Hold MIME data and facilitate file type guessing.
Implementations§
Source§impl MimeDB
impl MimeDB
pub fn add_records(&mut self, records: Vec<MimeTypeRecord>)
Source§impl MimeDB
impl MimeDB
Sourcepub fn query(&self, query: &FileQuery<'_>) -> Result<Answer<'_>, QueryError>
pub fn query(&self, query: &FileQuery<'_>) -> Result<Answer<'_>, QueryError>
Query the MIME database.
Sourcepub fn query_meta(&self, meta: &Metadata) -> Answer<'_>
pub fn query_meta(&self, meta: &Metadata) -> Answer<'_>
Use metadata to detect file types.
This function can only detect the inode/
types and application/octet-stream
.
Sourcepub fn query_filename<S>(&self, name: S) -> Answer<'_>
pub fn query_filename<S>(&self, name: S) -> Answer<'_>
Look up MIME type information based only on a filename.
Source§impl MimeDB
impl MimeDB
Sourcepub fn type_count(&self) -> usize
pub fn type_count(&self) -> usize
Get the number of known types.
Sourcepub fn glob_count(&self) -> usize
pub fn glob_count(&self) -> usize
Get the number of globs.
Sourcepub fn is_subtype(&self, typ: &str, sup: &str) -> bool
pub fn is_subtype(&self, typ: &str, sup: &str) -> bool
Query whether one type is a subtype of another.
Sourcepub fn description(&self, typ: &str) -> Option<&str>
pub fn description(&self, typ: &str) -> Option<&str>
Get the description of a string.
Sourcepub fn supertypes(&self, typ: &str) -> Vec<CachedString>
pub fn supertypes(&self, typ: &str) -> Vec<CachedString>
Get all known supertypes of the specified type (including itself).
Types are in discovery order, so closer supertypes are at the beginning of the list.
Sourcepub fn compare_types(&self, a: &str, b: &str) -> Ordering
pub fn compare_types(&self, a: &str, b: &str) -> Ordering
Order two types, where a type is less than its supertypes
Auto Trait Implementations§
impl !Freeze for MimeDB
impl !RefUnwindSafe for MimeDB
impl !Send for MimeDB
impl !Sync for MimeDB
impl Unpin for MimeDB
impl UnwindSafe for MimeDB
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