From 7035268413657b72bd67e0af692e110c0f06a196 Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Fri, 8 Apr 2022 13:31:53 +0200 Subject: [PATCH] Delete unneeded name() method from BarModuleFn trait --- swayrbar/src/bar/module.rs | 3 --- swayrbar/src/bar/module/battery.rs | 8 ++------ swayrbar/src/bar/module/date.rs | 6 +----- swayrbar/src/bar/module/sysinfo.rs | 6 +----- swayrbar/src/bar/module/window.rs | 10 +++------- 5 files changed, 7 insertions(+), 26 deletions(-) diff --git a/swayrbar/src/bar/module.rs b/swayrbar/src/bar/module.rs index c60fd2d..47790b1 100644 --- a/swayrbar/src/bar/module.rs +++ b/swayrbar/src/bar/module.rs @@ -28,9 +28,6 @@ pub trait BarModuleFn: Sync + Send { where Self: Sized; fn default_config(instance: String) -> config::ModuleConfig - where - Self: Sized; - fn name() -> &'static str where Self: Sized; fn get_config(&self) -> &config::ModuleConfig; diff --git a/swayrbar/src/bar/module/battery.rs b/swayrbar/src/bar/module/battery.rs index 4fa52ba..0ded74d 100644 --- a/swayrbar/src/bar/module/battery.rs +++ b/swayrbar/src/bar/module/battery.rs @@ -96,7 +96,7 @@ impl BarModuleFn for BarModuleBattery { fn default_config(instance: String) -> config::ModuleConfig { config::ModuleConfig { - name: Self::name().to_owned(), + name: NAME.to_owned(), instance, format: "🔋 Bat: {state_of_charge:{:5.1}}%, {state}, Health: {state_of_health:{:5.1}}%".to_owned(), html_escape: true, @@ -104,10 +104,6 @@ impl BarModuleFn for BarModuleBattery { } } - fn name() -> &'static str { - NAME - } - fn get_config(&self) -> &config::ModuleConfig { &self.config } @@ -115,7 +111,7 @@ impl BarModuleFn for BarModuleBattery { fn build(&self) -> s::Block { let text = get_text(&self.config); s::Block { - name: Some(Self::name().to_owned()), + name: Some(NAME.to_owned()), instance: Some(self.config.instance.clone()), full_text: text, align: Some(s::Align::Right), diff --git a/swayrbar/src/bar/module/date.rs b/swayrbar/src/bar/module/date.rs index 2af2592..b8ec3ca 100644 --- a/swayrbar/src/bar/module/date.rs +++ b/swayrbar/src/bar/module/date.rs @@ -46,10 +46,6 @@ impl BarModuleFn for BarModuleDate { } } - fn name() -> &'static str { - NAME - } - fn get_config(&self) -> &config::ModuleConfig { &self.config } @@ -57,7 +53,7 @@ impl BarModuleFn for BarModuleDate { fn build(&self) -> s::Block { let text = chrono::Local::now().format(&self.config.format).to_string(); s::Block { - name: Some(Self::name().to_owned()), + name: Some(NAME.to_owned()), instance: Some(self.config.instance.clone()), full_text: text, align: Some(s::Align::Right), diff --git a/swayrbar/src/bar/module/sysinfo.rs b/swayrbar/src/bar/module/sysinfo.rs index c68fd04..25007df 100644 --- a/swayrbar/src/bar/module/sysinfo.rs +++ b/swayrbar/src/bar/module/sysinfo.rs @@ -104,10 +104,6 @@ impl BarModuleFn for BarModuleSysInfo { } } - fn name() -> &'static str { - NAME - } - fn get_config(&self) -> &config::ModuleConfig { &self.config } @@ -115,7 +111,7 @@ impl BarModuleFn for BarModuleSysInfo { fn build(&self) -> s::Block { let updater = OnceRefresher::new(); s::Block { - name: Some(Self::name().to_owned()), + name: Some(NAME.to_owned()), instance: Some(self.config.instance.clone()), full_text: { let mut sys = self.system.lock().unwrap(); diff --git a/swayrbar/src/bar/module/window.rs b/swayrbar/src/bar/module/window.rs index ee61eb4..7598505 100644 --- a/swayrbar/src/bar/module/window.rs +++ b/swayrbar/src/bar/module/window.rs @@ -37,7 +37,7 @@ impl BarModuleFn for BarModuleWindow { fn default_config(instance: String) -> config::ModuleConfig { config::ModuleConfig { - name: Self::name().to_owned(), + name: NAME.to_owned(), instance, format: "🪟 {title} — {app_name}".to_owned(), html_escape: true, @@ -45,10 +45,6 @@ impl BarModuleFn for BarModuleWindow { } } - fn name() -> &'static str { - NAME - } - fn get_config(&self) -> &config::ModuleConfig { &self.config } @@ -61,14 +57,14 @@ impl BarModuleFn for BarModuleWindow { let text = match focused_win { Some(win) => { fmt_replace!(&self.config.format, self.config.html_escape, { - "title" |"name" => win.get_name(), + "title" | "name" => win.get_name(), "app_name" => win.get_app_name(), }) } None => String::new(), }; s::Block { - name: Some(Self::name().to_owned()), + name: Some(NAME.to_owned()), instance: Some(self.config.instance.clone()), full_text: text, align: Some(s::Align::Left),