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
Hostentries are rejected (via#[serde(deny_unknown_fields)]onHost) - The
Hostswrapper 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
impl Hosts
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty host collection.
Use add_host or map insertion methods to populate it.
Sourcepub fn add_host<N>(&mut self, name: N, host: Host)
pub fn add_host<N>(&mut self, name: N, host: Host)
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- TheHostinstance 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
impl BaseMethods for Hosts
Source§impl DerefTarget for Hosts
impl DerefTarget for Hosts
type Target = CustomTreeMap<Host>
Source§impl<'de> Deserialize<'de> for Hosts
impl<'de> Deserialize<'de> for Hosts
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
Source§impl JsonSchema for Hosts
impl JsonSchema for Hosts
Source§fn schema_id() -> Cow<'static, str>
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
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
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 moreAuto 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> 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