Skip to content

Commit

Permalink
fix imports to allow for serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteOtter committed Sep 11, 2023
1 parent 7296148 commit 3a4be59
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ edition = "2021"
clap = { version = "4.4.2", features = ["derive"] }
network-interface = "1.0.1"
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.105"
toml = "0.7.6"

[dev-dependencies]
Expand Down
9 changes: 5 additions & 4 deletions src/collectors/dmi_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::{
process::{Command, Output},
str::Split,
};
use serde::{Serialize, Deserialize};

/// ## DmiInformation
///
Expand All @@ -24,7 +25,7 @@ use std::{
/// * system_information: [`SystemInformation`](struct.SystemInformation) - Basic system information.
/// * chassis_information: [`ChassisInformation`](struct.ChassisInformation) - The type of asset.
/// * cpu_information: [`CpuInformation`](struct.CpuInformation) - Information about the processor(s).
#[derive(Debug)]
#[derive(Debug, Serialize, Deserialize)]
pub struct DmiInformation {
system_information: SystemInformation,
chassis_information: ChassisInformation,
Expand All @@ -42,7 +43,7 @@ pub struct DmiInformation {
/// * uuid: `String` - The UUID of the device.
/// * serial: `String` - The serial number of the machine.
/// * is_virtual: `bool` - Whether the machine is a virtual machine or not.
#[derive(Debug)]
#[derive(Debug, Serialize, Deserialize)]
struct SystemInformation {
vendor: String,
model: String,
Expand All @@ -60,7 +61,7 @@ struct SystemInformation {
/// * chassis_type: `String` - Type of the chassis.
/// * asset: `String`- Type of asset.
/// * chassis_serial: `Serial` - Serial number of the chassis.
#[derive(Debug)]
#[derive(Debug, Serialize, Deserialize)]
struct ChassisInformation {
chassis_type: String,
asset: String,
Expand All @@ -80,7 +81,7 @@ struct ChassisInformation {
/// * max_speed: `String`- The maximum speed of the CPU.
/// * voltage: `String` - The voltage the CPU runs at.
/// * status: `String` - Shows if the socket is enabled/disabled and populated/empty.
#[derive(Debug)]
#[derive(Debug, Serialize, Deserialize)]
struct CpuInformation {
version: String,
core_count: String,
Expand Down
3 changes: 2 additions & 1 deletion src/collectors/network_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//!
use network_interface::Addr::{V4, V6};
use network_interface::{NetworkInterface, NetworkInterfaceConfig};
use serde::{Serialize, Deserialize};
use std::fs;
use std::io::Read;
use std::net::IpAddr;
Expand All @@ -28,7 +29,7 @@ use super::collector_exceptions;
/// * is_physical - `bool` whether this device is a physical or virtual interface.
/// * is_connected - `bool` whether the interface is connected. Determined by if it has an address or not.
/// * interface_speed - `u32` the speed of the interface.
#[derive(Debug)]
#[derive(Debug, Serialize, Deserialize)]
pub struct NetworkInformation {
name: String,
interface_speed: Option<u32>,
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod collectors;
pub mod configuration;
mod configuration;
mod translator;

use clap::Parser;
use collectors::{dmi_collector, network_collector};
Expand Down
8 changes: 7 additions & 1 deletion src/translator/translator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
//! # The Translator module.
//!
//! This module will translate the information from the `collector` module into the `JSON`-Format the Netbox API
//! understands.
//! understands.
use serde::{Serialize, Deserialize};
use serde_json::{Result, Value};
use collectors::{dmi_collector, network_collector};

use crate::collectors;

0 comments on commit 3a4be59

Please sign in to comment.