mirror of
https://github.com/ClementTsang/bottom
synced 2024-11-21 19:53:05 +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 serde::{de::Error, Deserialize, Serialize};
|
||||
|
||||
use super::ProcWidgetData;
|
||||
use crate::{
|
||||
canvas::components::data_table::{ColumnHeader, SortsRow},
|
||||
|
@ -32,47 +30,6 @@ pub enum ProcColumn {
|
|||
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 {
|
||||
fn text(&self) -> Cow<'static, str> {
|
||||
match self {
|
||||
|
|
Loading…
Reference in a new issue