Backend trait refactors

- Refactor the confusing/bodgy consts backend macro to use a single
  `BackendInfo` struct
- Combine `supports_as_dependency()` and the `switches_dependency` into a single `Option` type as that is a better representation as it is an optional backend feature.
- Add more types like `Packages`, `Sections` for uniformity.
- Added a crate-private prelude and switches all imports to use a
  prelude glob import (excluding functions because it's nice to only be
  importing types)
- Refactored Backend section name in logging by implementing Display for
  `AnyBackend` that just prints the `section`
This commit is contained in:
ripytide
2024-04-24 17:03:42 +01:00
parent 15b50d8cb0
commit 17e42ca435
26 changed files with 524 additions and 560 deletions
+2 -4
View File
@@ -5,10 +5,8 @@ use std::io::{stdin, stdout, Write};
use anyhow::Result;
use crate::backend::backend_trait::Backend;
use crate::backend::todo_per_backend::ToDoPerBackend;
use crate::prelude::*;
use crate::ui::{get_user_confirmation, read_single_char_from_terminal};
use crate::{Group, Groups, Package};
use self::datastructures::{ContinueWithReview, ReviewAction, ReviewIntention, ReviewsPerBackend};
use self::strategy::Strategy;
@@ -24,7 +22,7 @@ pub fn review(todo_per_backend: ToDoPerBackend, groups: &Groups) -> Result<()> {
'outer: for (backend, packages) in todo_per_backend {
let mut actions = vec![];
for package in packages {
println!("{}: {package}", backend.get_section());
println!("{}: {package}", backend.backend_info().section);
match get_action_for_package(package, groups, &mut actions, &backend)? {
ContinueWithReview::Yes => continue,
ContinueWithReview::No => return Ok(()),