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
+3 -1
View File
@@ -5,6 +5,8 @@ use std::path::Path;
use anyhow::{bail, Context, Result};
use serde::{Deserialize, Serialize};
use crate::prelude::*;
// Update the master README if fields change.
/// Config for the program, as listed in `$XDG_CONFIG_HOME/pacdef/pacdef.toml`.
#[derive(Debug, Serialize, Deserialize)]
@@ -55,7 +57,7 @@ impl Config {
Ok(content) => content,
Err(e) => {
if e.kind() == ErrorKind::NotFound {
bail!(crate::Error::ConfigFileNotFound)
bail!(Error::ConfigFileNotFound)
}
bail!("unexpected error occurred: {e:?}");
}