pedant-types 0.7.0

Shared types for pedant capability analysis
Documentation
use std::sync::Arc;

use serde::{Deserialize, Serialize};

use crate::Capability;

/// A source code location.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash)]
pub struct SourceLocation {
    /// File path relative to the crate root.
    pub file: Arc<str>, // Arc: cloned per-finding from shared file path
    /// 1-based line number.
    pub line: usize,
    /// 1-based column number.
    pub column: usize,
}

/// A single capability finding at a specific location.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash)]
pub struct CapabilityFinding {
    /// The capability detected.
    pub capability: Capability,
    /// Where in source the capability was found.
    pub location: SourceLocation,
    /// Human-readable evidence (e.g. the function call or expression).
    pub evidence: Arc<str>,
    /// Whether this finding originates from a build script (compile-time execution).
    #[serde(default, skip_serializing_if = "is_false")]
    pub build_script: bool,
}

fn is_false(v: &bool) -> bool {
    !v
}