2021-08-28 07:54:01 +00:00
|
|
|
#![forbid(unsafe_code)]
|
|
|
|
#![warn(trivial_casts, unused_lifetimes, unused_qualifications)]
|
|
|
|
|
2021-08-28 07:59:04 +00:00
|
|
|
pub mod files;
|
2021-08-28 07:54:01 +00:00
|
|
|
pub mod findings;
|
|
|
|
pub mod formats;
|
2021-08-28 07:59:04 +00:00
|
|
|
pub mod mime_db;
|
2021-08-28 07:54:01 +00:00
|
|
|
pub mod parameters;
|
|
|
|
pub mod utils;
|
|
|
|
|
2021-08-28 07:59:04 +00:00
|
|
|
use cfg_if::cfg_if;
|
|
|
|
use once_cell::sync::OnceCell;
|
2021-08-28 07:54:01 +00:00
|
|
|
|
2021-09-24 08:11:25 +00:00
|
|
|
use crate::findings::Findings;
|
|
|
|
use crate::mime_db::MimeDb;
|
|
|
|
|
2021-08-28 08:00:31 +00:00
|
|
|
cfg_if! {
|
|
|
|
if #[cfg(not(all(target_endian = "big", target_pointer_width = "32")))] {
|
|
|
|
// most architectures
|
|
|
|
pub use smartstring::alias::String;
|
|
|
|
} else {
|
|
|
|
// powerpc and other big endian 32-bit archs
|
|
|
|
pub use std::string::String;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-28 07:54:01 +00:00
|
|
|
cfg_if! {
|
|
|
|
if #[cfg(any(all(unix, feature = "infer-backend"), all(not(unix), not(feature = "xdg-mime-backend"))))] {
|
|
|
|
/// A [OnceCell] holding an instance of [mime_db::MimeDb].
|
|
|
|
pub static MIMEDB: OnceCell<mime_db::InferDb> = OnceCell::new();
|
|
|
|
} else {
|
|
|
|
/// A [OnceCell] holding an instance of [mime_db::MimeDb].
|
|
|
|
pub static MIMEDB: OnceCell<mime_db::XdgDb> = OnceCell::new();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Initialises [`MIMEDB`] with a value dependent on the current backend.
|
|
|
|
pub fn init_db() {
|
|
|
|
cfg_if! {
|
|
|
|
if #[cfg(any(all(unix, feature = "infer-backend"), all(not(unix), not(feature = "xdg-mime-backend"))))] {
|
|
|
|
MIMEDB
|
|
|
|
.set(crate::mime_db::InferDb::init())
|
|
|
|
.or(Err("Failed to initialise Infer backend!"))
|
|
|
|
.unwrap();
|
|
|
|
} else {
|
|
|
|
MIMEDB
|
|
|
|
.set(crate::mime_db::XdgDb::init())
|
|
|
|
.or(Err("Failed to initialise XDG Mime backend!"))
|
|
|
|
.unwrap();
|
|
|
|
}
|
|
|
|
}
|
2021-08-28 07:59:04 +00:00
|
|
|
}
|