d-major 0.0.0

Traverse directory trees in parallel, using relative entries to minimize allocation and maximize parallelism.
Documentation
/*
 * Description: High-level API for visiting in parallel.
 *
 * Copyright (C) 2025 d@nny mc² <dmc2@hypnicjerk.ai>
 * SPDX-License-Identifier: LGPL-3.0-or-later
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

//! High-level API for visiting in parallel.

use crate::crawl::traits;


pub trait Visitor<'vfs, VFS>
where VFS: crate::vfs::traits::VFS
{
  type Err: From<VFS::Err>;

  fn visit_file(
    &mut self,
    ctx: VFS::Ctx<'vfs>,
    rel: VFS::OwnedPath,
    stat: Option<VFS::Stat>,
    recv: impl traits::RecvFile<'vfs, VFS, Self::Err>,
  );

  fn visit_file_handle(
    &mut self,
    ctx: VFS::Ctx<'vfs>,
    rel: VFS::OwnedPath,
    file: VFS::File,
    recv: impl traits::RecvErr<Self::Err>,
  );

  fn visit_link(
    &mut self,
    ctx: VFS::Ctx<'vfs>,
    rel: VFS::OwnedPath,
    stat: Option<VFS::Stat>,
    recv: impl traits::RecvLink<'vfs, VFS, Self::Err>,
  );

  fn visit_dir(
    &mut self,
    ctx: VFS::Ctx<'vfs>,
    rel: VFS::OwnedPath,
    stat: Option<VFS::Stat>,
    recv: impl traits::RecvDir<'vfs, VFS, Self::Err>,
  );

  fn visit_dir_entry<'dir>(
    &mut self,
    ctx: VFS::Ctx<'vfs>,
    entry: <VFS::Dir<'vfs> as crate::vfs::traits::DirectoryStream>::DirEntry<'dir>,
    recv: impl traits::RecvDirEntry<'vfs, VFS, Self::Err>,
  );
}

pub trait VisitorBuilder<VFS>
where VFS: crate::vfs::traits::VFS
{
  type Visitor<'vfs>: Visitor<'vfs, VFS>
  where Self: 'vfs;

  fn build<'vfs, 't: 'vfs>(&'t self) -> Self::Visitor<'vfs>;
}