Skip to main content

InventoryBuilder

Struct InventoryBuilder 

Source
pub struct InventoryBuilder {
    pub hosts: Option<Hosts>,
    pub groups: Option<Groups>,
    pub defaults: Option<Defaults>,
    pub transform_function: Option<TransformFunction>,
    pub transform_function_options: Option<TransformFunctionOptions>,
    pub connections: Option<Arc<ConnectionManager>>,
}
Expand description

Builder for constructing Inventory instances with custom configuration.

This builder provides a fluent interface for creating Inventory objects with optional hosts, groups, defaults, and transform settings. Fields that are not explicitly set will use their default values when build() is called.

§Fields

  • hosts - Optional hosts map. When set to Some(hosts), the provided hosts are used. When None, an empty Hosts map is used.
  • groups - Optional groups map. When set, the provided groups are used.
  • defaults - Optional defaults object. When set, the provided defaults are used.
  • transform_function - Optional transform function applied lazily on access.
  • transform_function_options - Optional JSON options passed to the transform.
  • connections - Optional connection manager. When None, a default ConnectionManager is created.

§Examples

use genja_core::inventory::{Host, Hosts, Inventory, BaseBuilderHost};

let mut hosts = Hosts::new();
let host = Host::builder().hostname("10.0.0.1").build();
hosts.add_host("router1", host);

let inventory = Inventory::builder()
    .hosts(hosts)
    .build();

Fields§

§hosts: Option<Hosts>§groups: Option<Groups>§defaults: Option<Defaults>§transform_function: Option<TransformFunction>§transform_function_options: Option<TransformFunctionOptions>§connections: Option<Arc<ConnectionManager>>

Implementations§

Source§

impl InventoryBuilder

Source

pub fn new() -> InventoryBuilder

Source

pub fn hosts(self, hosts: Hosts) -> Self

Source

pub fn groups(self, groups: Groups) -> Self

Source

pub fn defaults(self, defaults: Defaults) -> Self

Source

pub fn transform_function(self, transform: TransformFunction) -> Self

Source

pub fn transform_function_options( self, options: TransformFunctionOptions, ) -> Self

Source

pub fn connections(self, connections: ConnectionManager) -> Self

Source

pub fn build(self) -> Inventory

Trait Implementations§

Source§

impl Default for InventoryBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.