crosup_types/
inventory.rs1use indexmap::IndexMap;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct Inventory {
6 #[serde(serialize_with = "hcl::ser::labeled_block")]
7 pub server: IndexMap<String, ServerConnection>,
8}
9
10impl Default for Inventory {
11 fn default() -> Self {
12 let mut server = IndexMap::new();
13 server.insert("server1".into(), ServerConnection::default());
14 Self { server }
15 }
16}
17
18#[derive(Serialize, Deserialize, Debug, Clone)]
19pub struct ServerConnection {
20 #[serde(skip_serializing, skip_deserializing)]
21 pub name: String,
22 pub host: String,
23 pub username: String,
24 #[serde(skip_serializing_if = "Option::is_none")]
25 pub port: Option<u16>,
26}
27
28impl Default for ServerConnection {
29 fn default() -> Self {
30 Self {
31 name: "server1".to_string(),
32 host: "127.0.0.1".to_string(),
33 username: "username".to_string(),
34 port: Some(22),
35 }
36 }
37}