mirror of
https://github.com/ClementTsang/bottom
synced 2025-02-16 13:18:28 +00:00
refactor: clean up some unused serde code (#1619)
This commit is contained in:
parent
16a2fd6a41
commit
ae14685913
1 changed files with 0 additions and 43 deletions
|
@ -1,7 +1,5 @@
|
||||||
use std::{borrow::Cow, cmp::Reverse};
|
use std::{borrow::Cow, cmp::Reverse};
|
||||||
|
|
||||||
use serde::{de::Error, Deserialize, Serialize};
|
|
||||||
|
|
||||||
use super::ProcWidgetData;
|
use super::ProcWidgetData;
|
||||||
use crate::{
|
use crate::{
|
||||||
canvas::components::data_table::{ColumnHeader, SortsRow},
|
canvas::components::data_table::{ColumnHeader, SortsRow},
|
||||||
|
@ -32,47 +30,6 @@ pub enum ProcColumn {
|
||||||
GpuUtilPercent,
|
GpuUtilPercent,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> Deserialize<'de> for ProcColumn {
|
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
||||||
where
|
|
||||||
D: serde::Deserializer<'de>,
|
|
||||||
{
|
|
||||||
let value = String::deserialize(deserializer)?.to_lowercase();
|
|
||||||
match value.as_str() {
|
|
||||||
"cpu%" => Ok(ProcColumn::CpuPercent),
|
|
||||||
"mem" => Ok(ProcColumn::MemoryVal),
|
|
||||||
"mem%" => Ok(ProcColumn::MemoryPercent),
|
|
||||||
"pid" => Ok(ProcColumn::Pid),
|
|
||||||
"count" => Ok(ProcColumn::Count),
|
|
||||||
"name" => Ok(ProcColumn::Name),
|
|
||||||
"command" => Ok(ProcColumn::Command),
|
|
||||||
"read" | "r/s" | "rps" => Ok(ProcColumn::ReadPerSecond),
|
|
||||||
"write" | "w/s" | "wps" => Ok(ProcColumn::WritePerSecond),
|
|
||||||
"tread" | "t.read" => Ok(ProcColumn::TotalRead),
|
|
||||||
"twrite" | "t.write" => Ok(ProcColumn::TotalWrite),
|
|
||||||
"state" => Ok(ProcColumn::State),
|
|
||||||
"user" => Ok(ProcColumn::User),
|
|
||||||
"time" => Ok(ProcColumn::Time),
|
|
||||||
#[cfg(feature = "gpu")]
|
|
||||||
"gmem" => Ok(ProcColumn::GpuMem),
|
|
||||||
#[cfg(feature = "gpu")]
|
|
||||||
"gmem%" => Ok(ProcColumn::GpuMemPercent),
|
|
||||||
#[cfg(feature = "gpu")]
|
|
||||||
"gpu%" => Ok(ProcColumn::GpuUtilPercent),
|
|
||||||
_ => Err(Error::custom("doesn't match any column type")),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Serialize for ProcColumn {
|
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
||||||
where
|
|
||||||
S: serde::Serializer,
|
|
||||||
{
|
|
||||||
serializer.serialize_str(&self.text())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ColumnHeader for ProcColumn {
|
impl ColumnHeader for ProcColumn {
|
||||||
fn text(&self) -> Cow<'static, str> {
|
fn text(&self) -> Cow<'static, str> {
|
||||||
match self {
|
match self {
|
||||||
|
|
Loading…
Add table
Reference in a new issue