Skip to main content

Hosts

Struct Hosts 

Source
pub struct Hosts(/* private fields */);
Expand description

Collection of hosts keyed by name.

This type wraps a CustomTreeMap<Host> and is the primary container used for host inventory data. The map keys are host names used for logging/output.

§Deserialization

  • Unknown fields in individual Host entries are rejected (via #[serde(deny_unknown_fields)] on Host)
  • The Hosts wrapper itself accepts any valid map structure

§Examples

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

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

Implementations§

Source§

impl Hosts

Source

pub fn new() -> Self

Creates an empty host collection.

Use add_host or map insertion methods to populate it.

Source

pub fn add_host<N>(&mut self, name: N, host: Host)
where N: Into<String>,

Inserts a host into the collection under the provided name.

If a host with the same name already exists, it will be replaced with the new host. The name serves as the unique identifier for the host and is used in logs and output.

§Parameters
  • name - A string-like value that will be used as the unique identifier for the host. This name is used in logs and output to reference the host.
  • host - The Host instance to insert into the collection.
§Examples
use genja_core::inventory::{Host, Hosts, BaseBuilderHost};

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

Trait Implementations§

Source§

impl BaseMethods for Hosts

Source§

fn schema() -> String
where Self: Sized + JsonSchema,

Source§

impl Clone for Hosts

Source§

fn clone(&self) -> Hosts

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Hosts

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Hosts

Source§

fn default() -> Self

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

impl Deref for Hosts

Source§

type Target = <Hosts as DerefTarget>::Target

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for Hosts

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl DerefTarget for Hosts

Source§

impl<'de> Deserialize<'de> for Hosts

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for Hosts

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl Serialize for Hosts

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Hosts

§

impl RefUnwindSafe for Hosts

§

impl Send for Hosts

§

impl Sync for Hosts

§

impl Unpin for Hosts

§

impl UnsafeUnpin for Hosts

§

impl UnwindSafe for Hosts

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.