Struct MimeDB

Source
pub struct MimeDB { /* private fields */ }
Expand description

Hold MIME data and facilitate file type guessing.

Implementations§

Source§

impl MimeDB

Source

pub fn add_records(&mut self, records: Vec<MimeTypeRecord>)

Source

pub fn add_shared_mime_info(&mut self, info: SharedMimeInfo)

Source§

impl MimeDB

Source

pub fn query(&self, query: &FileQuery<'_>) -> Result<Answer<'_>, QueryError>

Query the MIME database.

Source

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.

Source

pub fn query_filename<S>(&self, name: S) -> Answer<'_>
where S: AsRef<OsStr>,

Look up MIME type information based only on a filename.

Source§

impl MimeDB

Source

pub fn new() -> MimeDB

construct a new, empty MIME database.

Source

pub fn type_count(&self) -> usize

Get the number of known types.

Source

pub fn glob_count(&self) -> usize

Get the number of globs.

Source

pub fn is_subtype(&self, typ: &str, sup: &str) -> bool

Query whether one type is a subtype of another.

Source

pub fn description(&self, typ: &str) -> Option<&str>

Get the description of a string.

Source

pub fn aliases(&self, typ: &str) -> Vec<&str>

Get the aliases of a type.

Source

pub fn parents(&self, typ: &str) -> Vec<&str>

Get the parents of a type.

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.