#![allow(clippy::multiple_crate_versions)]
use std::{marker::Sized, path::PathBuf};
pub use derive_macros::*;
#[cfg(feature = "directories")]
pub use directories::{self};
#[cfg(feature = "dirs")]
pub use dirs::{self};
#[cfg(feature = "etcetera")]
pub use etcetera::{self};
#[cfg(feature = "json")]
pub use json::{self};
#[cfg(feature = "toml")]
pub use toml::{self};
#[cfg(feature = "yaml")]
pub use yaml::{self};
#[derive(Debug, thiserror::Error)]
pub enum ConfigError {
#[error("None")]
None,
#[cfg(feature = "etcetera")]
#[error(transparent)]
HomeDir(#[from] etcetera::HomeDirError),
#[error(transparent)]
Io(#[from] std::io::Error),
#[cfg(feature = "json")]
#[error(transparent)]
Json(#[from] json::Error),
#[cfg(feature = "toml")]
#[error(transparent)]
TomlDe(#[from] toml::de::Error),
#[cfg(feature = "toml")]
#[error(transparent)]
TomlSer(#[from] toml::ser::Error),
#[cfg(feature = "yaml")]
#[error(transparent)]
Yaml(#[from] yaml::Error),
}
#[duplicate::duplicate_item(
language_struct_name;
[ DeriveJsonConfig ];
[ DeriveTomlConfig ];
[ DeriveYamlConfig ];
)]
pub trait language_struct_name {
fn path() -> Result<PathBuf, ConfigError>;
fn save(&self) -> Result<(), ConfigError>;
fn and_save(self) -> Result<Self, ConfigError>
where
Self: Sized;
fn load() -> Result<Self, ConfigError>
where
Self: Sized;
}