pub struct HostBuilder { /* private fields */ }Expand description
Builder for constructing Host instances.
This builder provides a fluent interface for creating hosts with optional configuration
fields. All fields start as None and can be set individually using the builder methods
before calling build() to create the final Host instance.
The builder implements the BaseBuilderHost trait, which provides standard methods for
setting connection parameters, group membership, and custom data. This allows for a
consistent interface across different inventory entity builders.
§Fields
-
hostname- Optional hostname or IP address for the host. This is the primary identifier used for network connections. -
port- Optional port number for connections. If not specified, defaults may be applied during connection parameter resolution. -
username- Optional username for authentication. Used for establishing connections to the host. -
password- Optional password for authentication. Used in conjunction with username for connection authentication. -
platform- Optional platform identifier (e.g., “linux”, “cisco_ios”). Used to determine platform-specific behavior and connection handling. -
groups- Optional parent group names that this host belongs to. Groups provide inherited configuration through the inventory hierarchy. -
data- Optional arbitrary JSON data associated with the host. Allows storing custom metadata and configuration that doesn’t fit standard fields. -
connection_options- Optional map of connection-specific overrides keyed by connection type. Allows per-connection-plugin-name customization of connection parameters.
§Examples
let host = Host::builder()
.hostname("10.0.0.1")
.port(22)
.username("admin")
.platform("linux")
.build();
assert_eq!(host.hostname(), Some("10.0.0.1"));
assert_eq!(host.port(), Some(22));