use serde::{Deserialize, Serialize};
use std::collections::{BTreeMap, BTreeSet};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ManifestInfo {
pub crate_name: String,
pub features_raw: BTreeMap<String, Vec<String>>,
pub all_deps: BTreeSet<String>,
pub optional_deps: BTreeSet<String>,
pub feature_deps: BTreeMap<String, BTreeSet<String>>,
pub dep_features: BTreeMap<String, BTreeSet<String>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DocumentDetails {
pub filename: String,
pub relative_path: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct UsedSymbols {
pub packages: std::collections::BTreeSet<String>, pub modules: std::collections::BTreeSet<String>, }
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FeatureNote {
pub feature_name: String,
pub deps: Vec<String>,
pub scope: Vec<String>,
pub corpus: bool,
pub used_in_file: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum UseKind {
UseStmt, ExternCrate, Attribute, MacroCall, Path, }
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UseSite {
pub dep: String, pub path: String, pub head: String, pub kind: UseKind,
pub line: usize, pub scope: String, }
pub type UseSites = BTreeMap<String, BTreeMap<String, usize>>;
pub type UseSitesCount = UseSites;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FileReport {
pub document: DocumentDetails,
pub used: UsedSymbols,
pub notes: Vec<FeatureNote>,
pub corpus_features: Vec<String>,
pub external_use_sites: Vec<UseSite>,
pub internal_use_sites: Vec<UseSite>,
pub external_dep_symbol_counts: UseSitesCount,
pub internal_dep_symbol_counts: UseSitesCount,
}
#[derive(Debug, Clone, Copy)]
pub enum PlanSection {
DocumentDetails,
FeatureNotes,
CorpusGates,
Custom(&'static str),
}
#[derive(Debug, Clone, Copy)]
pub enum ScaffoldKind {
Module,
Component,
Service,
Test,
}
impl ScaffoldKind {
pub fn parse(s: &str) -> Option<Self> {
match s.trim().to_lowercase().as_str() {
"module" => Some(Self::Module),
"component" => Some(Self::Component),
"service" => Some(Self::Service),
"test" => Some(Self::Test),
_ => None,
}
}
}
#[derive(Debug, Clone)]
pub struct ScaffoldRequest {
pub kind: ScaffoldKind,
pub name: String, pub module_path: Vec<String>, }
#[derive(Debug, Clone)]
pub struct ScaffoldOutput {
pub files: Vec<(std::path::PathBuf, String)>, }
impl ScaffoldOutput {
pub fn unsupported() -> Self { Self { files: vec![] } }
}