diff --git a/src/json/serialize.rs b/src/json/serialize.rs index 876af4db..cbd1ca77 100644 --- a/src/json/serialize.rs +++ b/src/json/serialize.rs @@ -38,7 +38,7 @@ impl SerializeState { } } -impl<'a> std::fmt::Debug for ValueRef<'a> { +impl std::fmt::Debug for ValueRef<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { ValueRef::String(s) => write!(f, "String({:?})", s), diff --git a/src/json/value.rs b/src/json/value.rs index b272c580..40faa9cb 100644 --- a/src/json/value.rs +++ b/src/json/value.rs @@ -22,7 +22,7 @@ pub enum ValueRef<'a> { Object(&'a dyn Serialize), } -impl<'a> Value<'a> { +impl Value<'_> { #[inline] pub fn as_str(&self) -> Option<&str> { match self { diff --git a/src/msgpack/serialize.rs b/src/msgpack/serialize.rs index f0e04305..48e69fb1 100644 --- a/src/msgpack/serialize.rs +++ b/src/msgpack/serialize.rs @@ -61,7 +61,7 @@ impl SerializeState { } } -impl<'a> std::fmt::Debug for ValueRef<'a> { +impl std::fmt::Debug for ValueRef<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { ValueRef::String(s) => write!(f, "String({:?})", s), diff --git a/src/presence/activity.rs b/src/presence/activity.rs index 39321251..094d05cb 100644 --- a/src/presence/activity.rs +++ b/src/presence/activity.rs @@ -58,10 +58,6 @@ impl ActivityContext { true } - pub fn update_custom_asset(&mut self, asset: Asset) { - self.custom_asset = Some(asset); - } - pub fn get_effective_name(&self) -> Cow { if let Some(custom) = &self.custom_asset { if !custom.name.is_empty() { diff --git a/src/session/mod.rs b/src/session/mod.rs index 84c15b0e..c6549c81 100644 --- a/src/session/mod.rs +++ b/src/session/mod.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + use std::collections::HashMap; use std::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard}; @@ -6,8 +8,6 @@ use crate::presence::types::Activity; use crate::types::config::PluginConfig; pub struct Session { - #[allow(dead_code)] - pub id: u32, pub workspace: Option, pub timestamp: Option, pub last_activity: Option, @@ -16,9 +16,8 @@ pub struct Session { } impl Session { - pub fn new(id: u32) -> Self { + pub fn new() -> Self { Self { - id, workspace: None, timestamp: None, last_activity: None, @@ -94,7 +93,7 @@ pub struct SessionManager { impl SessionManager { pub fn create_session(&self, id: u32, client: PipeClient) { let mut sessions = self.sessions.write().unwrap(); - let mut session = Session::new(id); + let mut session = Session::new(); session.set_pipe_client(client); sessions.insert(id, session); } diff --git a/src/types/config.rs b/src/types/config.rs index 59fc4bcb..03de41c0 100644 --- a/src/types/config.rs +++ b/src/types/config.rs @@ -200,7 +200,7 @@ impl Deserialize for Asset { let name = remove_field!(input, "name", |v| v.take_string()); let icon = remove_field!(input, "icon", |v| v.take_string()); let tooltip = remove_field!(input, "tooltip", |v| v.take_string()); - let ty = get_field!(input, "type", |v| v.as_uinteger()) + let ty = get_field!(input, "type", |v| v.as_str()) .try_into() .map_err(|_| "Invalid asset type")?; diff --git a/src/util/types.rs b/src/util/types.rs index 6cec8353..c2521c68 100644 --- a/src/util/types.rs +++ b/src/util/types.rs @@ -7,30 +7,16 @@ pub enum AssetType { Vcs, } -impl AssetType { - #[inline(always)] - pub fn from(value: &str) -> Option { - match value { - "language" => Some(AssetType::Language), - "file_browser" => Some(AssetType::FileBrowser), - "plugin_manager" => Some(AssetType::PluginManager), - "lsp_manager" => Some(AssetType::LspManager), - "vcs" => Some(AssetType::Vcs), - _ => None, - } - } -} - -impl TryFrom for AssetType { +impl TryFrom<&str> for AssetType { type Error = (); - fn try_from(value: u64) -> Result { + fn try_from(value: &str) -> Result { match value { - 0 => Ok(AssetType::Language), - 1 => Ok(AssetType::FileBrowser), - 2 => Ok(AssetType::PluginManager), - 3 => Ok(AssetType::LspManager), - 4 => Ok(AssetType::Vcs), + "language" => Ok(AssetType::Language), + "file_browser" => Ok(AssetType::FileBrowser), + "plugin_manager" => Ok(AssetType::PluginManager), + "lsp_manager" => Ok(AssetType::LspManager), + "vcs" => Ok(AssetType::Vcs), _ => Err(()), } }