pub struct NetworksFileConfig {
pub networks: Vec<NetworkFileConfig>,
/* private fields */
}
Expand description
Represents the complete configuration for all defined networks.
This structure holds configurations loaded from a file or a directory of files and provides methods to validate and process them, including resolving inheritance.
Fields§
§networks: Vec<NetworkFileConfig>
Implementations§
Source§impl NetworksFileConfig
impl NetworksFileConfig
Sourcepub fn new(networks: Vec<NetworkFileConfig>) -> Result<Self, ConfigFileError>
pub fn new(networks: Vec<NetworkFileConfig>) -> Result<Self, ConfigFileError>
Creates a new NetworksFileConfig
instance from a vector of network configurations.
§Returns
Ok(Self)
if all network names are unique within their respective types and the instance is successfully created.Err(ConfigFileError)
if duplicate network names are found within the same network type.
Sourcepub fn get_network(
&self,
network_type: ConfigFileNetworkType,
name: &str,
) -> Option<&NetworkFileConfig>
pub fn get_network( &self, network_type: ConfigFileNetworkType, name: &str, ) -> Option<&NetworkFileConfig>
Retrieves a network configuration by its network type and name.
§Arguments
network_type
- The type of the network to retrieve.name
- The name of the network to retrieve.
§Returns
Some(&NetworkFileConfig)
if a network with the given type and name exists.None
if no network with the given type and name is found.
Sourcepub fn flatten(&self) -> Result<NetworksFileConfig, ConfigFileError>
pub fn flatten(&self) -> Result<NetworksFileConfig, ConfigFileError>
Builds a new set of networks with all inheritance chains resolved and flattened.
This method processes all networks and their inheritance relationships to produce a set of fully expanded network configurations where each network includes all properties from its parent networks, with any overrides applied.
§Returns
Result<NetworksFileConfig, ConfigFileError>
containing either the flattened configuration or an error if any inheritance issues are encountered.
Sourcepub fn validate(&self) -> Result<(), ConfigFileError>
pub fn validate(&self) -> Result<(), ConfigFileError>
Validates the entire networks configuration structure.
§Returns
Ok(())
if the entire configuration is valid.Err(ConfigFileError)
if any validation fails (duplicate names, invalid inheritance, incompatible inheritance types, or errors from individual network validations).
Sourcepub fn iter(&self) -> impl Iterator<Item = &NetworkFileConfig>
pub fn iter(&self) -> impl Iterator<Item = &NetworkFileConfig>
Returns an iterator over all networks.
Sourcepub fn networks_by_type(
&self,
network_type: ConfigFileNetworkType,
) -> impl Iterator<Item = &NetworkFileConfig>
pub fn networks_by_type( &self, network_type: ConfigFileNetworkType, ) -> impl Iterator<Item = &NetworkFileConfig>
Filters networks by type.
Sourcepub fn network_names(&self) -> impl Iterator<Item = &str>
pub fn network_names(&self) -> impl Iterator<Item = &str>
Gets all network names.
Sourcepub fn first(&self) -> Option<&NetworkFileConfig>
pub fn first(&self) -> Option<&NetworkFileConfig>
Returns the first network in the configuration.
§Returns
Some(&NetworkFileConfig)
if there is at least one network.None
if the configuration is empty.
Trait Implementations§
Source§impl Clone for NetworksFileConfig
impl Clone for NetworksFileConfig
Source§fn clone(&self) -> NetworksFileConfig
fn clone(&self) -> NetworksFileConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for NetworksFileConfig
impl Debug for NetworksFileConfig
Source§impl Default for NetworksFileConfig
impl Default for NetworksFileConfig
Source§fn default() -> NetworksFileConfig
fn default() -> NetworksFileConfig
Source§impl<'de> Deserialize<'de> for NetworksFileConfig
Custom deserialization logic for NetworksFileConfig
.
impl<'de> Deserialize<'de> for NetworksFileConfig
Custom deserialization logic for NetworksFileConfig
.
This allows NetworksFileConfig
to be created from either a direct list of network
configurations, a path string pointing to a directory of configuration files, or null/missing
for the default path (“./config/networks”).
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>,
Source§impl Index<usize> for NetworksFileConfig
impl Index<usize> for NetworksFileConfig
Auto Trait Implementations§
impl Freeze for NetworksFileConfig
impl RefUnwindSafe for NetworksFileConfig
impl Send for NetworksFileConfig
impl Sync for NetworksFileConfig
impl Unpin for NetworksFileConfig
impl UnwindSafe for NetworksFileConfig
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Encode for T
impl<T> Encode for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
] or
a color-specific method, such as [OwoColorize::green
], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
] or
a color-specific method, such as [OwoColorize::on_yellow
], Read more