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
impl Db
Sourcepub fn new() -> Result<Self, Box<dyn Error>>
pub fn new() -> Result<Self, Box<dyn Error>>
Creates a new database instance and loads the embedded data files.
Sourcepub fn lookup_by_extension(&self, extension: &str) -> Option<&Info>
pub fn lookup_by_extension(&self, extension: &str) -> Option<&Info>
Sourcepub fn lookup_by_content_type(&self, content_type: &str) -> Option<&Info>
pub fn lookup_by_content_type(&self, content_type: &str) -> Option<&Info>
Sourcepub fn lookup_by_filename(&self, filename: &str) -> Option<&Info>
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 recognizedNoneif 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> 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