jump_dir/
crawl.rs

1/*
2 * Description: Crawl the filesystem in parallel.
3 *
4 * Copyright (C) 2025 d@nny mc² <dmc2@hypnicjerk.ai>
5 * SPDX-License-Identifier: LGPL-3.0-or-later
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19 */
20
21//! Crawl the filesystem in parallel.
22
23use std::{borrow::Cow, ffi, fs, path::PathBuf};
24
25struct EntryHandle<'d> {
26  inner: &'d fs::DirEntry,
27}
28
29impl<'d> EntryHandle<'d> {
30  pub(crate) const fn new(inner: &'d fs::DirEntry) -> Self { Self { inner } }
31
32  pub fn full_path(&self) -> PathBuf { self.inner.path() }
33}
34
35pub struct FileEntry<'d> {
36  inner: &'d fs::DirEntry,
37}
38
39impl<'d> FileEntry<'d> {
40  pub(crate) const fn new(inner: &'d fs::DirEntry) -> Self { Self { inner } }
41
42  pub fn file_name(&self) -> ffi::OsString { self.inner.file_name() }
43}
44
45pub struct DirEntry<'d> {
46  inner: &'d fs::DirEntry,
47}
48
49impl<'d> DirEntry<'d> {
50  pub(crate) const fn new(inner: &'d fs::DirEntry) -> Self { Self { inner } }
51
52  pub fn file_name(&self) -> ffi::OsString { self.inner.file_name() }
53}
54
55
56pub trait Visitor {}
57
58pub trait VisitorBuilder {
59  type Visitor<'s>: Visitor
60  where Self: 's;
61
62  fn build<'s, 't: 's>(&'t self) -> Self::Visitor<'s>;
63}