1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Configuration traits and utilities.
//!
//! This module provides a common configuration trait that can be
//! implemented by configuration types across the workspace.
use crateResult;
use ;
use fmt;
/// Configuration trait that all configuration types should implement.
///
/// This trait provides a common interface for configuration objects,
/// ensuring they can be serialized/deserialized and validated.
///
/// # Example
/// ```
/// use rh_foundation::Config;
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Debug, Serialize, Deserialize)]
/// struct MyConfig {
/// name: String,
/// port: u16,
/// }
///
/// impl Config for MyConfig {
/// fn validate(&self) -> rh_foundation::Result<()> {
/// if self.port == 0 {
/// return Err(rh_foundation::FoundationError::InvalidInput(
/// "Port cannot be 0".to_string()
/// ));
/// }
/// Ok(())
/// }
/// }
/// ```