pub struct SourceUnit {
pub relative_path: PathBuf,
pub absolute_path: PathBuf,
pub language: Language,
pub is_header: bool,
pub content_hash: ContentHash,
pub source_bytes: Arc<[u8]>,
pub byte_len: u64,
pub package: Option<String>,
pub crate_name: Option<String>,
pub target_kind: TargetKind,
}Expand description
One physical source file selected for analysis.
A file appears at most once: uniqueness is keyed on its normalized path, so
a header shared by several translation units is registered a single time.
content_hash additionally identifies byte-identical
copies at different paths.
Fields§
§relative_path: PathBufPath relative to the scan root, used for display and stable ordering.
absolute_path: PathBufAbsolute path, used to read the file.
language: LanguageDetected language.
is_header: boolWhether the file is a header rather than a translation unit.
content_hash: ContentHashContent fingerprint.
source_bytes: Arc<[u8]>Exact bytes whose hash was recorded and which frontends must analyse.
Keeping this shared allocation prevents a second filesystem read after discovery, so a source edit cannot make the stored hash describe different bytes from the parsed program.
byte_len: u64File size in bytes.
package: Option<String>Owning Cargo package, when the file sits inside one.
crate_name: Option<String>The crate a compiler knows this file by, when the package layout says which crate that is.
Not the package: one package holds a library, its binaries and a crate per test file, and a compiler is asked about one of those rather than about the package they share.
target_kind: TargetKindRole of the file in its package.
Trait Implementations§
Source§impl Clone for SourceUnit
impl Clone for SourceUnit
Source§fn clone(&self) -> SourceUnit
fn clone(&self) -> SourceUnit
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more