cordance-scan 0.1.0

Cordance repository scanners. Deterministic surface classification.
Documentation
//! Repository scanners. Deterministic surface classification by path and filename.

#![forbid(unsafe_code)]
#![deny(clippy::unwrap_used, clippy::expect_used)]
#![cfg_attr(test, allow(clippy::expect_used, clippy::unwrap_used))]

use camino::Utf8PathBuf;
use cordance_core::source::{SourceClass, SourceRecord};

pub mod blocked;
pub mod classifier;
pub mod hasher;
pub mod walker;

#[derive(Debug, thiserror::Error)]
pub enum ScanError {
    #[error("io error reading {path}: {source}")]
    Io {
        path: Utf8PathBuf,
        #[source]
        source: std::io::Error,
    },
    #[error("path is not valid utf-8: {0}")]
    NonUtf8Path(String),
}

/// Top-level scan entrypoint. Delegates to `walker::walk`.
#[allow(clippy::missing_errors_doc)]
pub fn scan_repo(root: &Utf8PathBuf) -> Result<Vec<SourceRecord>, ScanError> {
    walker::walk(root)
}

/// Classify a path using only its repo-relative location. No content reads.
#[must_use]
pub fn classify_by_path(rel_path: &str) -> SourceClass {
    classifier::classify(rel_path)
}