fif/lib.rs
1// SPDX-FileCopyrightText: 2021-2024 Lynnesbian
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4//! This library consists of all of the things fif needs to run. It only exists as a library to separate code, and to
5//! make documentation and testing a bit easier. I don't recommend using this as a library for your crate, as it may
6//! have breaking changes without incrementing the major version - it's really only meant to be a place for fif's
7//! internals to live.
8//!
9//! You can view [fif's README](https://gitlab.com/Lynnesbian/fif/-/blob/master/README.md#fif) to learn more.
10
11#![forbid(unsafe_code)]
12#![warn(
13 trivial_casts,
14 unused_lifetimes,
15 unused_qualifications,
16 missing_copy_implementations,
17 unused_allocation
18)]
19
20pub mod files;
21pub mod findings;
22pub mod formats;
23pub mod mime_db;
24pub mod parameters;
25pub mod utils;
26
27use cfg_if::cfg_if;
28
29use crate::findings::Findings;
30use crate::mime_db::MimeDb;
31
32cfg_if! {
33 if #[cfg(not(all(target_endian = "big", target_pointer_width = "32")))] {
34 /// On most architectures, this is a type alias for [`SmartString`](crate). However, on [architectures
35 /// unsupported by `smartstring`](https://github.com/bodil/smartstring/blob/v0.2.9/src/config.rs#L91-L93), this
36 /// is simply an alias to [`std::string::String`].
37 pub use smartstring::alias::String;
38 } else {
39 /// On most architectures, this is a type alias for [`SmartString`](crate). However, on [architectures
40 /// unsupported by `smartstring`](https://github.com/bodil/smartstring/blob/v0.2.9/src/config.rs#L91-L93), this
41 /// is simply an alias to [`std::string::String`].
42 // one particular arch that this needs to be turned off for is powerpc (the 32 bit variant that the pre-G5
43 // powerpc macs used)
44 pub use std::string::String;
45 }
46}
47cfg_if! {
48 if #[cfg(any(all(unix, feature = "infer-backend"), all(not(unix), not(feature = "xdg-mime-backend"))))] {
49 /// A [`Lazy`] holding an instance of [`mime_db::MimeDb`]. Initialised at program startup.
50 pub static MIMEDB: std::sync::LazyLock<mime_db::InferDb> = std::sync::LazyLock::new(mime_db::InferDb::init);
51 } else {
52 /// A [`Lazy`] holding an instance of [`mime_db::MimeDb`]. Initialised at program startup.
53 pub static MIMEDB: std::sync::LazyLock<mime_db::XdgDb> = std::sync::LazyLock::new(mime_db::XdgDb::init);
54 }
55}