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:
@@ -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:?}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user