pub struct InventoryConfig { /* private fields */ }Expand description
Inventory loader configuration.
The plugin name defaults from GENJA_INVENTORY_PLUGIN. When present,
transform_function is attached to the built Inventory after the raw
inventory files are loaded. The transform itself is then applied lazily
when inventory data is accessed or resolved.
Implementations§
Source§impl InventoryConfig
impl InventoryConfig
pub fn builder() -> InventoryConfigBuilder
pub fn plugin(&self) -> &str
pub fn options(&self) -> &OptionsConfig
pub fn transform_function(&self) -> Option<&str>
pub fn transform_function_options(&self) -> Option<&TransformFunctionOptions>
Source§impl InventoryConfig
impl InventoryConfig
Sourcepub fn load_inventory_files(
&self,
) -> Result<(Hosts, Option<Groups>, Option<Defaults>), InventoryLoadError>
pub fn load_inventory_files( &self, ) -> Result<(Hosts, Option<Groups>, Option<Defaults>), InventoryLoadError>
Loads inventory data from configured file paths.
This method reads and deserializes inventory files (hosts, groups, and defaults)
based on the paths specified in the options field. If a file path is not
provided for a particular inventory component, a default or empty value is used.
§Returns
Returns a Result containing a tuple of:
Hosts- The loaded hosts inventory. If no hosts file is specified, returns an emptyHostsinstance.Option<Groups>- The loaded groups inventory, orNoneif no groups file is specified.Option<Defaults>- The loaded defaults inventory, orNoneif no defaults file is specified.
§Errors
Returns InventoryLoadError if:
- Any specified file cannot be read
- Any file contains invalid JSON or YAML syntax
- A file has an unsupported format (not .json, .yaml, or .yml)
§Examples
use genja_core::settings::InventoryConfig;
let config = InventoryConfig::default();
match config.load_inventory_files() {
Ok((hosts, groups, defaults)) => {
println!("Loaded {} hosts", hosts.len());
}
Err(e) => eprintln!("Failed to load inventory: {}", e),
}Trait Implementations§
Source§impl Clone for InventoryConfig
impl Clone for InventoryConfig
Source§fn clone(&self) -> InventoryConfig
fn clone(&self) -> InventoryConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InventoryConfig
impl Debug for InventoryConfig
Source§impl Default for InventoryConfig
impl Default for InventoryConfig
Source§impl<'de> Deserialize<'de> for InventoryConfig
impl<'de> Deserialize<'de> for InventoryConfig
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
Auto Trait Implementations§
impl Freeze for InventoryConfig
impl RefUnwindSafe for InventoryConfig
impl Send for InventoryConfig
impl Sync for InventoryConfig
impl Unpin for InventoryConfig
impl UnsafeUnpin for InventoryConfig
impl UnwindSafe for InventoryConfig
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