dia_files/
lib.rs

1/*
2==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--
3
4Dia-Files
5
6Copyright (C) 2019-2024  Anonymous
7
8There are several releases over multiple years,
9they are listed as ranges, such as: "2019-2024".
10
11This program is free software: you can redistribute it and/or modify
12it under the terms of the GNU Lesser General Public License as published by
13the Free Software Foundation, either version 3 of the License, or
14(at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19GNU Lesser General Public License for more details.
20
21You should have received a copy of the GNU Lesser General Public License
22along with this program.  If not, see <https://www.gnu.org/licenses/>.
23
24::--::--::--::--::--::--::--::--::--::--::--::--::--::--::--::--
25*/
26
27//! # Dia-Files
28//!
29//! ## Project
30//!
31//! - License: GNU Lesser General Public License, either version 3, or (at your option) any later version.
32//! - _This project follows [Semantic Versioning 2.0.0]_
33//!
34//! ## Features
35//!
36//! - Finding files recursively: [`find_files()`][::find_files()].
37//! - And some functions for reading bytes from [`Read`][r://Read], [`Path`][r://Path]...
38//!
39//! ## Notes
40//!
41//! - Tests require some symbolic link files in `tests/` directory. At the time of writing this note, Cargo does not allow publishing crates
42//!   containing symbolic link files. So for source publishing on <https://crates.io/crates/dia-files>, they are stripped. However, the
43//!   repository has all those files.
44//!
45//! - Documentation is built with all features. Some of them are optional. If you see components from other crates, you can view source to see
46//!   what features are required.
47//!
48//! [Semantic Versioning 2.0.0]: https://semver.org/spec/v2.0.0.html
49//!
50//! [::find_files()]: fn.find_files.html
51//! [r://Read]: https://doc.rust-lang.org/std/io/trait.Read.html
52//! [r://Path]: https://doc.rust-lang.org/std/path/struct.Path.html
53
54#![warn(missing_docs)]
55
56#![feature(doc_cfg)]
57
58// ╔═════════════════╗
59// ║   IDENTIFIERS   ║
60// ╚═════════════════╝
61
62macro_rules! code_name  { () => { "dia-files" }}
63macro_rules! version    { () => { "0.23.2" }}
64
65/// # Crate name
66pub const NAME: &str = "Dia-Files";
67
68/// # Crate code name
69pub const CODE_NAME: &str = code_name!();
70
71/// # ID of this crate
72pub const ID: &str = concat!(
73    "4026816f-f9aa2c43-932ab1fd-2ec6adbd-1f288e5d-6b8b2ab7-0ed2e589-ae211f06-",
74    "0cd6923c-0ce42168-355a8795-4450b615-6439a1c9-cf2bb0e7-f966c980-060f1a13",
75);
76
77/// # Crate version
78pub const VERSION: &str = version!();
79
80/// # Crate release date (year/month/day)
81pub const RELEASE_DATE: (u16, u8, u8) = (2024, 12, 10);
82
83/// # Tag, which can be used for logging...
84pub const TAG: &str = concat!(code_name!(), "::4026816f::", version!());
85
86// ╔════════════════════╗
87// ║   IMPLEMENTATION   ║
88// ╚════════════════════╝
89
90#[cfg(feature="libc")]
91extern crate alloc;
92
93/// # Wrapper for format!(), which prefixes your optional message with: crate::TAG, module_path!(), line!()
94macro_rules! __ {
95    ($($arg: tt)+) => {
96        format!("[{tag}][{module_path}-{line}] {msg}", tag=crate::TAG, module_path=module_path!(), line=line!(), msg=format!($($arg)+))
97    };
98    () => {
99        format!("[{tag}][{module_path}-{line}] (internal error)", tag=crate::TAG, module_path=module_path!(), line=line!())
100    };
101}
102
103/// # Makes new std::io::Error
104macro_rules! err {
105    ($kind: path, $($arg: tt)+) => { std::io::Error::new($kind, __!($($arg)+)) };
106    ($($arg: tt)+) => { err!(std::io::ErrorKind::Other, $($arg)+) };
107    () => { std::io::Error::new(std::io::ErrorKind::Other, __!()) };
108}
109
110macro_rules! async_call { ($f: expr) => {{
111    #[cfg(feature="async-std")]
112    let r = $f.await;
113    #[cfg(not(feature="async-std"))]
114    let r = $f;
115    r
116}}}
117
118#[test]
119fn test_crate_version() {
120    assert_eq!(VERSION, env!("CARGO_PKG_VERSION"));
121}
122
123pub mod debts;
124pub mod filter;
125pub mod version_info;
126
127#[cfg(feature="async-std")]
128mod async_buf_reader;
129mod file_system;
130mod limit;
131mod path_ext;
132mod permissions;
133mod root;
134mod sealed;
135
136pub use self::{
137    file_system::*,
138    limit::*,
139    path_ext::*,
140    permissions::*,
141    root::*,
142};
143
144#[cfg(feature="async-std")]
145pub use self::async_buf_reader::*;
146
147pub (crate) use self::sealed::*;
148
149/// # Result type used in this crate
150pub type Result<T> = std::result::Result<T, std::io::Error>;