capsule_core/import/
scan.rs1use std::path::PathBuf;
2
3use crate::domain::{DetectionMethod, MemberRole, StackType};
4use crate::metadata::AssetType;
5
6#[derive(Debug, Clone)]
9pub struct ImportCandidate {
10 pub source_paths: Vec<PathBuf>,
12 pub detected_type: AssetType,
14 pub stack_type: Option<StackType>,
16 pub detection_method: Option<DetectionMethod>,
18 pub detection_key: Option<String>,
20 pub members: Vec<(PathBuf, MemberRole)>,
22}
23
24impl ImportCandidate {
25 pub fn primary_path(&self) -> &PathBuf {
27 self.members
28 .iter()
29 .find(|(_, r)| *r == MemberRole::Primary)
30 .map_or(&self.source_paths[0], |(p, _)| p)
31 }
32}
33
34#[derive(Debug, Default)]
36pub struct ScanResult {
37 pub candidates: Vec<ImportCandidate>,
38}
39
40impl ScanResult {
41 pub fn total_files(&self) -> usize {
42 self.candidates.iter().map(|c| c.source_paths.len()).sum()
43 }
44}