#[non_exhaustive]pub struct SantaConfig {
pub sources: Vec<KnownSources>,
pub packages: Vec<String>,
pub custom_sources: Option<SourceList>,
pub _groups: Option<HashMap<KnownSources, Vec<String>>>,
pub log_level: u8,
}Expand description
Main configuration structure for Santa
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.sources: Vec<KnownSources>§packages: Vec<String>§custom_sources: Option<SourceList>§_groups: Option<HashMap<KnownSources, Vec<String>>>§log_level: u8Implementations§
Source§impl SantaConfig
impl SantaConfig
Sourcepub fn new(sources: Vec<KnownSources>, packages: Vec<String>) -> Self
pub fn new(sources: Vec<KnownSources>, packages: Vec<String>) -> Self
Create a new SantaConfig from the given sources and packages. The
custom_sources, _groups, and log_level fields are initialized to
their defaults.
Sourcepub fn load_from_str(config_str: &str) -> Result<Self>
pub fn load_from_str(config_str: &str) -> Result<Self>
Load configuration from a string (CCL format)
§Example
use santa_data::config::SantaConfig;
let ccl = r#"
sources =
= brew
= cargo
packages =
= git
"#;
let config = SantaConfig::load_from_str(ccl).unwrap();
assert_eq!(config.sources.len(), 2);Sourcepub fn load_from(file: &Path) -> Result<Self>
pub fn load_from(file: &Path) -> Result<Self>
Load configuration from a file path
§Example
use santa_data::config::SantaConfig;
use std::path::Path;
let config = SantaConfig::load_from(Path::new("santa.ccl")).unwrap();Sourcepub fn validate_basic(&self) -> Result<()>
pub fn validate_basic(&self) -> Result<()>
Basic configuration validation
Checks for:
- At least one source is configured
- No duplicate sources
- Warns about duplicate packages
Trait Implementations§
Source§impl Clone for SantaConfig
impl Clone for SantaConfig
Source§impl Debug for SantaConfig
impl Debug for SantaConfig
Source§impl<'de> Deserialize<'de> for SantaConfig
impl<'de> Deserialize<'de> for SantaConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for SantaConfig
impl Serialize for SantaConfig
Source§impl Validate for SantaConfig
impl Validate for SantaConfig
Source§impl<'v_a> ValidateArgs<'v_a> for SantaConfig
impl<'v_a> ValidateArgs<'v_a> for SantaConfig
Auto Trait Implementations§
impl Freeze for SantaConfig
impl RefUnwindSafe for SantaConfig
impl Send for SantaConfig
impl Sync for SantaConfig
impl Unpin for SantaConfig
impl UnsafeUnpin for SantaConfig
impl UnwindSafe for SantaConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more