Db

Struct Db 

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

Internal database for MIME type lookups.

This struct manages the hash maps used for fast MIME type lookups by file extension and content type.

Implementations§

Source§

impl Db

Source

pub fn new() -> Result<Self, Box<dyn Error>>

Creates a new database instance and loads the embedded data files.

Source

pub fn lookup_by_extension(&self, extension: &str) -> Option<&Info>

Looks up MIME information by file extension.

The lookup is case-insensitive, trying the exact extension first, then falling back to lowercase.

§Arguments
  • extension - File extension (with or without leading dot)
§Returns
  • Some(&Info) if the extension is found
  • None if the extension is not recognized
Source

pub fn lookup_by_content_type(&self, content_type: &str) -> Option<&Info>

Looks up MIME information by content type.

§Arguments
  • content_type - MIME content type (e.g., “text/plain”)
§Returns
  • Some(&Info) if the content type is found
  • None if the content type is not recognized
Source

pub fn lookup_by_filename(&self, filename: &str) -> Option<&Info>

Looks up MIME information by filename.

Extracts the file extension from the filename and performs a lookup. The lookup is case-insensitive.

§Arguments
  • filename - Full filename or path
§Returns
  • Some(&Info) if the file extension is recognized
  • None if the file has no extension or the extension is not recognized

Auto Trait Implementations§

§

impl Freeze for Db

§

impl RefUnwindSafe for Db

§

impl Send for Db

§

impl Sync for Db

§

impl Unpin for Db

§

impl UnwindSafe for Db

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.