pub struct ConfigDiff;Expand description
Configuration diff utilities for detecting differences between configurations
This utility provides methods to compare configuration instances and detect what fields have changed. Useful for configuration hot-reload, migration, auditing, and change tracking.
§Examples
use chie_shared::{ConfigDiff, RetryConfig};
let old_config = RetryConfig::default();
let mut new_config = RetryConfig::default();
new_config.max_attempts = 10;
let changes = ConfigDiff::retry_config(&old_config, &new_config);
assert_eq!(changes.len(), 1);
assert_eq!(changes[0].field, "max_attempts");
assert_eq!(changes[0].new_value, "10");Implementations§
Source§impl ConfigDiff
impl ConfigDiff
Sourcepub fn network_config(
old: &NetworkConfig,
new: &NetworkConfig,
) -> Vec<ConfigChange>
pub fn network_config( old: &NetworkConfig, new: &NetworkConfig, ) -> Vec<ConfigChange>
Detect differences between two NetworkConfig instances
Returns a list of changes between the old and new configurations.
Compares all fields including max_connections, timeouts, relay/DHT settings,
bootstrap peers, and listen addresses.
§Examples
use chie_shared::{ConfigDiff, NetworkConfig};
let old = NetworkConfig::default();
let mut new = NetworkConfig::default();
new.max_connections = 200;
new.enable_relay = false;
let changes = ConfigDiff::network_config(&old, &new);
assert_eq!(changes.len(), 2);
// Check for specific changes
let fields: Vec<&str> = changes.iter().map(|c| c.field.as_str()).collect();
assert!(fields.contains(&"max_connections"));
assert!(fields.contains(&"enable_relay"));Sourcepub fn retry_config(old: &RetryConfig, new: &RetryConfig) -> Vec<ConfigChange>
pub fn retry_config(old: &RetryConfig, new: &RetryConfig) -> Vec<ConfigChange>
Detect differences between two RetryConfig instances
Returns a list of changes between the old and new configurations.
§Examples
use chie_shared::{ConfigDiff, RetryConfigBuilder};
let old = RetryConfigBuilder::new()
.max_attempts(3)
.initial_backoff_ms(100)
.build();
let new = RetryConfigBuilder::new()
.max_attempts(5)
.initial_backoff_ms(200)
.build();
let changes = ConfigDiff::retry_config(&old, &new);
assert_eq!(changes.len(), 2);
// Verify specific changes
let max_attempts_change = changes.iter()
.find(|c| c.field == "max_attempts")
.unwrap();
assert_eq!(max_attempts_change.old_value, "3");
assert_eq!(max_attempts_change.new_value, "5");Sourcepub fn feature_flags(
old: &FeatureFlags,
new: &FeatureFlags,
) -> Vec<ConfigChange>
pub fn feature_flags( old: &FeatureFlags, new: &FeatureFlags, ) -> Vec<ConfigChange>
Detect differences between two FeatureFlags instances
Returns a list of changes between the old and new configurations.
§Examples
use chie_shared::{ConfigDiff, FeatureFlagsBuilder};
let old = FeatureFlagsBuilder::new()
.experimental(false)
.debug_mode(false)
.build();
let new = FeatureFlagsBuilder::new()
.experimental(true)
.debug_mode(true)
.performance_profiling(true)
.build();
let changes = ConfigDiff::feature_flags(&old, &new);
assert!(changes.len() >= 2); // At least experimental and debug_mode changed
// Check for experimental flag change
let exp_change = changes.iter()
.find(|c| c.field == "experimental")
.unwrap();
assert_eq!(exp_change.old_value, "false");
assert_eq!(exp_change.new_value, "true");Auto Trait Implementations§
impl Freeze for ConfigDiff
impl RefUnwindSafe for ConfigDiff
impl Send for ConfigDiff
impl Sync for ConfigDiff
impl Unpin for ConfigDiff
impl UnwindSafe for ConfigDiff
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