cargo_coupling/balance/
action.rs1#[derive(Debug, Clone)]
3pub enum RefactoringAction {
4 IntroduceTrait {
6 suggested_name: String,
7 methods: Vec<String>,
8 },
9 MoveCloser { target_location: String },
11 ExtractAdapter {
13 adapter_name: String,
14 purpose: String,
15 },
16 SplitModule { suggested_modules: Vec<String> },
18 SimplifyAbstraction { direct_usage: String },
20 BreakCycle { suggested_direction: String },
22 StabilizeInterface { interface_name: String },
24 General { action: String },
26 AddGetters { fields: Vec<String> },
28 IntroduceNewtype {
30 suggested_name: String,
31 wrapped_type: String,
32 },
33}
34
35impl std::fmt::Display for RefactoringAction {
36 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
37 match self {
38 RefactoringAction::IntroduceTrait {
39 suggested_name,
40 methods,
41 } => {
42 write!(
43 f,
44 "Introduce trait `{}` with methods: {}",
45 suggested_name,
46 methods.join(", ")
47 )
48 }
49 RefactoringAction::MoveCloser { target_location } => {
50 write!(f, "Move component to `{}`", target_location)
51 }
52 RefactoringAction::ExtractAdapter {
53 adapter_name,
54 purpose,
55 } => {
56 write!(f, "Extract adapter `{}` to {}", adapter_name, purpose)
57 }
58 RefactoringAction::SplitModule { suggested_modules } => {
59 write!(f, "Split into modules: {}", suggested_modules.join(", "))
60 }
61 RefactoringAction::SimplifyAbstraction { direct_usage } => {
62 write!(f, "Replace with direct usage: {}", direct_usage)
63 }
64 RefactoringAction::BreakCycle {
65 suggested_direction,
66 } => {
67 write!(f, "Break cycle by {}", suggested_direction)
68 }
69 RefactoringAction::StabilizeInterface { interface_name } => {
70 write!(f, "Add stable interface `{}`", interface_name)
71 }
72 RefactoringAction::General { action } => {
73 write!(f, "{}", action)
74 }
75 RefactoringAction::AddGetters { fields } => {
76 write!(f, "Add getter methods for: {}", fields.join(", "))
77 }
78 RefactoringAction::IntroduceNewtype {
79 suggested_name,
80 wrapped_type,
81 } => {
82 write!(
83 f,
84 "Introduce newtype: `struct {}({});`",
85 suggested_name, wrapped_type
86 )
87 }
88 }
89 }
90}