1use reqwest;
2use serde::{Deserialize, Serialize};
3use smbioslib::*;
4
5#[derive(Serialize, Deserialize)]
6pub struct MotherboardInfo {
7 pub manufacturer: String,
8 pub product_name: String,
9}
10
11pub async fn send_collected_info() -> Result<(), Box<dyn std::error::Error>> {
12 let info = collect_info()?;
13 send_info(&info).await?;
14 Ok(())
15}
16
17fn collect_info() -> Result<MotherboardInfo, Box<dyn std::error::Error>> {
18 let mut manufacturer = String::new();
19 let mut product_name = String::new();
20
21 let data = table_load_from_device()?;
22 for baseboard in data.collect::<SMBiosBaseboardInformation>() {
23 manufacturer = baseboard.manufacturer().to_string();
24 product_name = baseboard.product().to_string();
25 }
26
27 Ok(MotherboardInfo {
28 manufacturer,
29 product_name,
30 })
31}
32
33async fn send_info(info: &MotherboardInfo) -> Result<(), reqwest::Error> {
34 let client = reqwest::Client::new();
35 let res = client
36 .post("http://your-web-service-url.com/api")
37 .json(&info)
38 .send()
39 .await?;
40
41 if res.status().is_success() {
42 Ok(())
43 } else {
44 Err(res.error_for_status().unwrap_err())
45 }
46}