Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added serde_json capabilities to public structures #76

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ cc = "1"

[dependencies]
libc = "0.2.29"
serde = {version = "1.0.118", features = ["derive"]}
15 changes: 11 additions & 4 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
//!

extern crate libc;
extern crate serde;

use serde::{Deserialize, Serialize};



use std::ffi;
use std::fmt;
Expand Down Expand Up @@ -39,7 +44,7 @@ static OS_KERN_BOOTTIME: libc::c_int = 21;

/// System load average value.
#[repr(C)]
#[derive(Debug)]
#[derive(Debug, Serialize)]
pub struct LoadAvg {
/// Average load within one minite.
pub one: f64,
Expand All @@ -51,7 +56,7 @@ pub struct LoadAvg {

/// System memory information.
#[repr(C)]
#[derive(Debug)]
#[derive(Debug, Deserialize, Serialize)]
pub struct MemInfo {
/// Total physical memory.
pub total: u64,
Expand All @@ -66,9 +71,11 @@ pub struct MemInfo {
pub swap_free: u64,
}

// // implement Serialize for MemInfo

/// The os release info of Linux
#[derive(Debug)]
#[derive(Default)]
#[derive(Default, Deserialize, Serialize)]
pub struct LinuxOSReleaseInfo {
pub id: Option<String>,
pub id_like: Option<String>,
Expand All @@ -94,7 +101,7 @@ pub struct LinuxOSReleaseInfo {

/// Disk information.
#[repr(C)]
#[derive(Debug)]
#[derive(Debug, Deserialize, Serialize)]
pub struct DiskInfo {
pub total: u64,
pub free: u64,
Expand Down