use std::path::PathBuf;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Layout {
Adjacent,
DirOwner,
}
#[derive(Debug, Clone)]
pub struct Config {
pub verify: bool,
pub rustfmt: bool,
pub dry_run: bool,
pub min_groups: usize,
}
impl Default for Config {
fn default() -> Self {
Config {
verify: true,
rustfmt: true,
dry_run: false,
min_groups: 2,
}
}
}
#[derive(Debug, Clone)]
pub struct VisEdit {
pub rel_start: usize,
pub rel_end: usize,
pub text: String,
}
#[derive(Debug, Clone)]
pub struct ReExport {
pub vis: String,
pub name: String,
pub cfg_attrs: Vec<String>,
}
#[derive(Debug, Clone)]
pub struct MovedItem {
pub group: String,
pub leading_comment: String,
pub text: String,
pub vis_edits: Vec<VisEdit>,
pub reexport: Option<ReExport>,
pub order: usize,
}
#[derive(Debug, Clone)]
pub struct GroupFile {
pub stem: String,
pub item_indices: Vec<usize>,
}
#[derive(Debug, Clone)]
pub struct SplitPlan {
pub source_path: PathBuf,
pub layout: Layout,
pub out_dir: PathBuf,
pub parent_contents: String,
pub moved: Vec<MovedItem>,
pub files: Vec<GroupFile>,
}
impl SplitPlan {
pub fn is_noop(&self) -> bool {
self.files.len() < 2
}
}
#[derive(Debug)]
pub enum FileOutcome {
Split { files: Vec<PathBuf> },
Skipped(String),
RolledBack(String),
}