1#![allow(clippy::multiple_crate_versions)]
2
3use std::{marker::Sized, path::PathBuf};
4
5pub use derive_macros::*;
6#[cfg(feature = "dirs")]
7pub use dirs::{self};
8use duplicate::duplicate_item;
9#[cfg(feature = "json")]
10pub use json::{self};
11use thiserror::Error;
12#[cfg(feature = "toml")]
13pub use toml::{self};
14#[cfg(feature = "yaml")]
15pub use yaml::{self};
16
17#[derive(Debug, Error)]
18pub enum ConfigError {
19 #[error("None")]
20 None,
21
22 #[error("{0}")]
23 Io(#[from] std::io::Error),
24
25 #[cfg(feature = "json")]
26 #[error("{0}")]
27 Json(#[from] json::Error),
28
29 #[cfg(feature = "toml")]
30 #[error("{0}")]
31 TomlDe(#[from] toml::de::Error),
32
33 #[cfg(feature = "toml")]
34 #[error("{0}")]
35 TomlSer(#[from] toml::ser::Error),
36
37 #[cfg(feature = "yaml")]
38 #[error("{0}")]
39 Yaml(#[from] yaml::Error),
40}
41
42#[duplicate_item(
43 language_struct_name;
44 [ DeriveJsonConfig ];
45 [ DeriveTomlConfig ];
46 [ DeriveYamlConfig ];
47)]
48pub trait language_struct_name {
49 fn path() -> Result<PathBuf, ConfigError>;
53
54 fn save(&self) -> Result<(), ConfigError>;
56
57 fn load() -> Result<Self, ConfigError>
59 where
60 Self: Sized;
61}