Skip to main content

HostBuilder

Struct HostBuilder 

Source
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));

Implementations§

Source§

impl HostBuilder

Source

pub fn new() -> Self

Trait Implementations§

Source§

impl BaseBuilderHost for HostBuilder

Source§

type Output = Host

Source§

fn hostname<S>(self, hostname: S) -> Self
where S: Into<String>,

Source§

fn port(self, port: u16) -> Self

Updates the port and returns the updated builder.
Source§

fn username<S>(self, username: S) -> Self
where S: Into<String>,

Updates the username and returns the updated builder.
Source§

fn password<S>(self, password: S) -> Self
where S: Into<String>,

Updates the password and returns the updated builder.
Source§

fn platform<S>(self, platform: S) -> Self
where S: Into<String>,

Updates the platform and returns the updated builder.
Source§

fn groups(self, groups: ParentGroups) -> Self

Updates the groups and returns the updated builder.
Source§

fn data(self, data: Data) -> Self

Updates the data and returns the updated builder.
Source§

fn connection_options<S>(self, name: S, options: ConnectionOptions) -> Self
where S: Into<String>,

Updates the connection options and returns the updated builder.
Source§

fn build(self) -> Host

Builds the struct from the updated builder and returns final struct object.
Source§

impl Default for HostBuilder

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.