archunit/common/extraction/
source_file.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::path::{Path, PathBuf};

/// One Rust source file belonging to a Cargo workspace member.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[non_exhaustive]
pub struct SourceFile {
    path: PathBuf,
    identifier: String,
}

impl SourceFile {
    pub(crate) fn new(path: PathBuf, identifier: String) -> Self {
        Self { path, identifier }
    }

    /// Returns the absolute filesystem path used for reading the source.
    #[must_use]
    pub fn path(&self) -> &Path {
        &self.path
    }

    /// Returns the normalized workspace-relative identifier used by graph nodes and patterns.
    #[must_use]
    pub fn identifier(&self) -> &str {
        &self.identifier
    }
}