summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@ifm.com>2022-07-15 08:50:24 +0200
committerMatthias Beyer <matthias.beyer@ifm.com>2022-07-15 08:50:24 +0200
commitb7166d552970dd2add81c28c84d498dfba6f4980 (patch)
tree75ab0d2875ebe7aca0114e1f2220a6ebbfa85498
parentd4d12adc58091823800d338128a07665d4178337 (diff)
parent5bc4c969bfdbc031716c4df64771563a93c5a778 (diff)
Merge branch 'feature/add_tedge_api/clippy-fixes' into feature/add_tedge_api_impl
-rw-r--r--crates/core/tedge_api/src/plugin.rs12
-rw-r--r--crates/core/tedge_api/tedge_config_derive/src/lib.rs4
-rw-r--r--crates/core/tedge_core/src/communication.rs2
-rw-r--r--crates/core/tedge_core/src/configuration.rs9
-rw-r--r--crates/core/tedge_core/src/lib.rs2
-rw-r--r--crates/core/tedge_core/src/message_handler.rs2
-rw-r--r--crates/core/tedge_core/src/reactor.rs12
-rw-r--r--crates/core/tedge_lib/src/config/port.rs6
-rw-r--r--crates/core/tedge_lib/src/config/socket_addr.rs6
-rw-r--r--crates/core/tedge_lib/src/iter/send_all.rs2
-rw-r--r--crates/core/tedge_lib/src/pubsub.rs12
-rw-r--r--plugins/plugin_httpstop/src/lib.rs5
-rw-r--r--plugins/plugin_inotify/src/config.rs1
-rw-r--r--plugins/plugin_log/src/lib.rs4
-rw-r--r--plugins/plugin_measurement_filter/src/plugin.rs6
-rw-r--r--plugins/plugin_notification/src/plugin.rs6
-rw-r--r--plugins/plugin_sysstat/src/error.rs1
-rw-r--r--plugins/plugin_sysstat/src/main/cpu.rs13
-rw-r--r--plugins/plugin_sysstat/src/main/disk_usage.rs4
-rw-r--r--plugins/plugin_sysstat/src/main/load.rs2
-rw-r--r--plugins/plugin_sysstat/src/main/network.rs4
-rw-r--r--plugins/plugin_sysstat/src/main/process.rs12
-rw-r--r--tedge/src/config.rs8
-rw-r--r--tedge/src/logging.rs8
-rw-r--r--tedge/src/main.rs4
-rw-r--r--tedge/src/registry.rs4
26 files changed, 63 insertions, 88 deletions
diff --git a/crates/core/tedge_api/src/plugin.rs b/crates/core/tedge_api/src/plugin.rs
index d905c220..29b6fd3e 100644
--- a/crates/core/tedge_api/src/plugin.rs
+++ b/crates/core/tedge_api/src/plugin.rs
@@ -601,10 +601,10 @@ impl MessageBundle for () {
impl<P: Plugin> DoesHandle<()> for P {
fn into_built_plugin(self) -> BuiltPlugin {
- fn handle_message<'a, PLUG: Plugin>(
- _plugin: &'a dyn Any,
+ fn handle_message<PLUG: Plugin>(
+ _plugin: &dyn Any,
_message: InternalMessage,
- ) -> BoxFuture<'a, Result<(), PluginError>> {
+ ) -> BoxFuture<Result<(), PluginError>> {
unreachable!()
}
BuiltPlugin {
@@ -626,10 +626,10 @@ impl MessageBundle for AnyMessages {
impl<P: Plugin + Handle<crate::message::AnyMessage>> DoesHandle<AnyMessages> for P {
fn into_built_plugin(self) -> BuiltPlugin {
- fn handle_message<'a, PLUG: Plugin + Handle<crate::message::AnyMessage>>(
- plugin: &'a dyn Any,
+ fn handle_message<PLUG: Plugin + Handle<crate::message::AnyMessage>>(
+ plugin: &dyn Any,
message: InternalMessage,
- ) -> BoxFuture<'a, Result<(), PluginError>> {
+ ) -> BoxFuture<Result<(), PluginError>> {
let plug = match plugin.downcast_ref::<PLUG>() {
Some(p) => p,
None => {
diff --git a/crates/core/tedge_api/tedge_config_derive/src/lib.rs b/crates/core/tedge_api/tedge_config_derive/src/lib.rs
index b2a97098..91e3f585 100644
--- a/crates/core/tedge_api/tedge_config_derive/src/lib.rs
+++ b/crates/core/tedge_api/tedge_config_derive/src/lib.rs
@@ -226,7 +226,7 @@ pub fn derive_config(input: TS) -> TS {
.named
.iter()
.map(|f| ConfigField {
- ident: &f.ident.as_ref().unwrap(),
+ ident: f.ident.as_ref().unwrap(),
ty: &f.ty,
docs: extract_docs_from_attributes(f.attrs.iter()),
})
@@ -320,7 +320,7 @@ pub fn derive_config(input: TS) -> TS {
.named
.iter()
.map(|f| ConfigField {
- ident: &f.ident.as_ref().unwrap(),
+ ident: f.ident.as_ref().unwrap(),
ty: &f.ty,
docs: extract_docs_from_attributes(f.attrs.iter()),
})
diff --git a/crates/core/tedge_core/src/communication.rs b/crates/core/tedge_core/src/communication.rs
index 8fec5102..76c8939d 100644
--- a/crates/core/tedge_core/src/communication.rs
+++ b/crates/core/tedge_core/src/communication.rs
@@ -97,7 +97,7 @@ impl CorePluginDirectory {
/// plugin named `plugin_name`.
pub fn for_plugin_named(self: Arc<Self>, plugin_name: &str) -> PluginDirectory {
PluginDirectory {
- core: self.clone(),
+ core: self,
plugin_name: plugin_name.to_string(),
}
}
diff --git a/crates/core/tedge_core/src/configuration.rs b/crates/core/tedge_core/src/configuration.rs
index f9d49b89..987be958 100644
--- a/crates/core/tedge_core/src/configuration.rs
+++ b/crates/core/tedge_core/src/configuration.rs
@@ -4,7 +4,6 @@ use std::{
path::{Path, PathBuf},
};
-
use tedge_api::PluginBuilder;
use tracing::debug;
@@ -78,12 +77,12 @@ impl InstanceConfiguration {
pub async fn verify_with_builder(
&self,
plugin_name: &str,
- builder: &Box<dyn PluginBuilder<PluginDirectory>>,
+ builder: &dyn PluginBuilder<PluginDirectory>,
root_config_path: &Path,
) -> Result<toml::Value, PluginConfigurationError> {
match self {
InstanceConfiguration::Config(cfg) => builder
- .verify_configuration(&cfg)
+ .verify_configuration(cfg)
.await
.map_err(|e| {
PluginConfigurationError::Verification(PluginConfigVerificationError {
@@ -95,7 +94,7 @@ impl InstanceConfiguration {
InstanceConfiguration::ConfigFilePath(path) => {
async fn inner(
plugin_name: &str,
- builder: &Box<dyn PluginBuilder<PluginDirectory>>,
+ builder: &dyn PluginBuilder<PluginDirectory>,
root_config_path: &Path,
path: &Path,
) -> Result<toml::Value, PluginConfigurationError> {
@@ -134,7 +133,7 @@ impl InstanceConfiguration {
})
}
- inner(plugin_name, builder, root_config_path, &path).await
+ inner(plugin_name, builder, root_config_path, path).await
}
}
}
diff --git a/crates/core/tedge_core/src/lib.rs b/crates/core/tedge_core/src/lib.rs
index 212120bf..ede90e39 100644
--- a/crates/core/tedge_core/src/lib.rs
+++ b/crates/core/tedge_core/src/lib.rs
@@ -117,7 +117,7 @@ impl TedgeApplication {
debug!("Verifying {}", plugin_cfg.kind().as_ref());
let res = plugin_cfg
.configuration()
- .verify_with_builder(&plugin_name, builder, self.config_path())
+ .verify_with_builder(&plugin_name, &**builder, self.config_path())
.await;
Ok(res?)
diff --git a/crates/core/tedge_core/src/message_handler.rs b/crates/core/tedge_core/src/message_handler.rs
index 61ff5de0..6ada8159 100644
--- a/crates/core/tedge_core/src/message_handler.rs
+++ b/crates/core/tedge_core/src/message_handler.rs
@@ -47,7 +47,7 @@ pub fn make_message_handler(
Ok(permit) => Some(permit),
Err(_acquire_err) => {
error!("Semaphore closed in CoreTask unexpectedly");
- return None;
+ None
}
}
})
diff --git a/crates/core/tedge_core/src/reactor.rs b/crates/core/tedge_core/src/reactor.rs
index c1c8df3c..07d06c01 100644
--- a/crates/core/tedge_core/src/reactor.rs
+++ b/crates/core/tedge_core/src/reactor.rs
@@ -4,7 +4,6 @@ use std::sync::Arc;
use futures::StreamExt;
use itertools::Itertools;
-use tedge_api::message::MessageType;
use tedge_api::plugin::BuiltPlugin;
use tedge_api::PluginExt;
use tokio::sync::mpsc::channel;
@@ -79,13 +78,7 @@ impl Reactor {
.0
.plugin_builders()
.get(pconfig.kind().as_ref())
- .map(|(handle_types, _)| {
- handle_types
- .get_types()
- .into_iter()
- .cloned()
- .collect::<Vec<MessageType>>()
- })
+ .map(|(handle_types, _)| handle_types.get_types().to_vec())
.ok_or_else(|| {
PluginInstantiationError::KindNotFound(PluginKindUnknownError {
name: pconfig.kind().as_ref().to_string(),
@@ -303,6 +296,7 @@ impl Reactor {
.map(|cfg| cfg.configuration())
}
+ #[allow(clippy::borrowed_box)]
fn find_plugin_builder<'a>(
&'a self,
plugin_kind: &PluginKind,
@@ -346,7 +340,7 @@ impl Reactor {
)?;
let config = match config
- .verify_with_builder(plugin_name, builder, root_config_path)
+ .verify_with_builder(plugin_name, &**builder, root_config_path)
.instrument(trace_span!("core.config_verification"))
.await
{
diff --git a/crates/core/tedge_lib/src/config/port.rs b/crates/core/tedge_lib/src/config/port.rs
index edffd2f9..b80e87ac 100644
--- a/crates/core/tedge_lib/src/config/port.rs
+++ b/crates/core/tedge_lib/src/config/port.rs
@@ -7,9 +7,9 @@
#[serde(transparent)]
pub struct Port(u16);
-impl Into<u16> for Port {
- fn into(self) -> u16 {
- self.0
+impl From<Port> for u16 {
+ fn from(p: Port) -> Self {
+ p.0
}
}
diff --git a/crates/core/tedge_lib/src/config/socket_addr.rs b/crates/core/tedge_lib/src/config/socket_addr.rs
index db2c46ce..f76fc5bc 100644
--- a/crates/core/tedge_lib/src/config/socket_addr.rs
+++ b/crates/core/tedge_lib/src/config/socket_addr.rs
@@ -7,9 +7,9 @@
)]
pub struct SocketAddr(std::net::SocketAddr);
-impl Into<std::net::SocketAddr> for SocketAddr {
- fn into(self) -> std::net::SocketAddr {
- self.0
+impl From<SocketAddr> for std::net::SocketAddr {
+ fn from(sa: SocketAddr) -> Self {
+ sa.0
}
}
diff --git a/crates/core/tedge_lib/src/iter/send_all.rs b/crates/core/tedge_lib/src/iter/send_all.rs
index 43b82fd4..b6caa609 100644
--- a/crates/core/tedge_lib/src/iter/send_all.rs
+++ b/crates/core/tedge_lib/src/iter/send_all.rs
@@ -99,7 +99,7 @@ where
>;
fn next(&mut self) -> Option<Self::Item> {
- let timeout = self.timeout.clone();
+ let timeout = self.timeout;
self.inner.next().map(|(msg, address)| {
async move {
diff --git a/crates/core/tedge_lib/src/pubsub.rs b/crates/core/tedge_lib/src/pubsub.rs
index 609b8039..00fe2a5b 100644
--- a/crates/core/tedge_lib/src/pubsub.rs
+++ b/crates/core/tedge_lib/src/pubsub.rs
@@ -15,8 +15,8 @@ mod request {
pd: std::marker::PhantomData<M>,
}
- impl<M: Message> SubscribeRequest<M> {
- pub fn new() -> Self {
+ impl<M: Message> Default for SubscribeRequest<M> {
+ fn default() -> Self {
Self {
pd: std::marker::PhantomData,
}
@@ -71,11 +71,11 @@ mod reply {
tedge_api::util::generate_composite_uuid(SubscribeReplyUuid::TYPE_UUID, M::TYPE_UUID);
}
- impl<M: Message> Into<Result<tokio::sync::broadcast::Receiver<M>, PluginError>>
- for SubscribeReply<M>
+ impl<M: Message> From<SubscribeReply<M>>
+ for Result<tokio::sync::broadcast::Receiver<M>, PluginError>
{
- fn into(self) -> Result<tokio::sync::broadcast::Receiver<M>, PluginError> {
- self.0
+ fn from(sr: SubscribeReply<M>) -> Self {
+ sr.0
}
}
diff --git a/plugins/plugin_httpstop/src/lib.rs b/plugins/plugin_httpstop/src/lib.rs
index c109f826..dacb7f8d 100644
--- a/plugins/plugin_httpstop/src/lib.rs
+++ b/plugins/plugin_httpstop/src/lib.rs
@@ -69,10 +69,7 @@ where
plugin_dir: &PD,
) -> Result<tedge_api::plugin::BuiltPlugin, tedge_api::PluginError> {
debug!("Instantiating HttpStopPlugin");
- let config = config
- .clone()
- .try_into::<HttpStopConfig>()
- .map_err(Error::from)?;
+ let config = config.try_into::<HttpStopConfig>().map_err(Error::from)?;
let plugin = HttpStopPlugin {
cancellation_token,
diff --git a/plugins/plugin_inotify/src/config.rs b/plugins/plugin_inotify/src/config.rs
index 290feeca..9aa3614f 100644
--- a/plugins/plugin_inotify/src/config.rs
+++ b/plugins/plugin_inotify/src/config.rs
@@ -24,6 +24,7 @@ fn fail_on_err_default() -> bool {
#[derive(serde::Deserialize, Copy, Clone, Debug, tedge_api::Config)]
#[config(untagged)]
#[allow(non_camel_case_types)]
+#[allow(clippy::upper_case_acronyms)]
pub enum Watchmode {
/// File was accessed
/// When watching a directory, this event is only triggered for objects inside the directory,
diff --git a/plugins/plugin_log/src/lib.rs b/plugins/plugin_log/src/lib.rs
index b7706849..55367090 100644
--- a/plugins/plugin_log/src/lib.rs
+++ b/plugins/plugin_log/src/lib.rs
@@ -23,8 +23,8 @@ pub struct LogPluginBuilder<MB: MessageBundle> {
_pd: PhantomData<MB>,
}
-impl<MB: MessageBundle> LogPluginBuilder<MB> {
- pub fn new() -> Self {
+impl<MB: MessageBundle> Default for LogPluginBuilder<MB> {
+ fn default() -> Self {
LogPluginBuilder { _pd: PhantomData }
}
}
diff --git a/plugins/plugin_measurement_filter/src/plugin.rs b/plugins/plugin_measurement_filter/src/plugin.rs
index c68f4a62..0e664d41 100644
--- a/plugins/plugin_measurement_filter/src/plugin.rs
+++ b/plugins/plugin_measurement_filter/src/plugin.rs
@@ -57,10 +57,8 @@ impl Handle<Measurement> for MeasurementFilterPlugin {
trace!(plugin.filter = ?self.filter, ?value, "Applying filter");
if value.apply_filter(&self.filter) {
let _ = self.target.send_and_wait(message).await;
- } else {
- if let Some(ftarget) = self.filtered_target.as_ref() {
- let _ = ftarget.send_and_wait(message).await;
- }
+ } else if let Some(ftarget) = self.filtered_target.as_ref() {
+ let _ = ftarget.send_and_wait(message).await;
}
}
Ok(())
diff --git a/plugins/plugin_notification/src/plugin.rs b/plugins/plugin_notification/src/plugin.rs
index be5386d5..1394e583 100644
--- a/plugins/plugin_notification/src/plugin.rs
+++ b/plugins/plugin_notification/src/plugin.rs
@@ -55,11 +55,7 @@ impl Handle<Measurement> for NotificationPlugin {
trace!(?message, "Sending notification for measurement");
let _ = self
.notify_addr
- .send_and_wait(
- self.raise
- .clone()
- .into_notification(self.raise_msg.to_string()),
- )
+ .send_and_wait(self.raise.into_notification(self.raise_msg.to_string()))
.await;
trace!(?message, "Forwarding measurement");
diff --git a/plugins/plugin_sysstat/src/error.rs b/plugins/plugin_sysstat/src/error.rs
index c5016070..d7908b98 100644
--- a/plugins/plugin_sysstat/src/error.rs
+++ b/plugins/plugin_sysstat/src/error.rs
@@ -1,4 +1,5 @@
#[derive(Debug, miette::Diagnostic, thiserror::Error)]
+#[allow(clippy::enum_variant_names)]
pub(crate) enum Error {
#[error("Failed to parse configuration")]
ConfigParseFailed(toml::de::Error),
diff --git a/plugins/plugin_sysstat/src/main/cpu.rs b/plugins/plugin_sysstat/src/main/cpu.rs
index 0f305903..84c93c8e 100644
--- a/plugins/plugin_sysstat/src/main/cpu.rs
+++ b/plugins/plugin_sysstat/src/main/cpu.rs
@@ -98,10 +98,7 @@ pub async fn main_cpu(state: Arc<Mutex<CPUState>>) -> Result<(), PluginError> {
let fut = state
.addrs
.send_and_wait({
- Measurement::new(
- state.global_processor_info_name.to_string(),
- measurement.clone(),
- )
+ Measurement::new(state.global_processor_info_name.to_string(), measurement)
})
.collect::<SendAllResult<Measurement>>();
sending.push(fut);
@@ -142,10 +139,7 @@ pub async fn main_cpu(state: Arc<Mutex<CPUState>>) -> Result<(), PluginError> {
let fut = state
.addrs
.send_and_wait({
- Measurement::new(
- state.physical_core_count_name.to_string(),
- measurement.clone(),
- )
+ Measurement::new(state.physical_core_count_name.to_string(), measurement)
})
.collect::<SendAllResult<Measurement>>();
sending.push(fut);
@@ -171,6 +165,9 @@ pub async fn main_cpu(state: Arc<Mutex<CPUState>>) -> Result<(), PluginError> {
.map(|_| ())
}
+// TODO: There might be some optimization opportunity here with the number of arguments for this
+// function
+#[allow(clippy::too_many_arguments)]
fn get_processor_info_measurements(
info: &sysinfo::Processor,
frequency: bool,
diff --git a/plugins/plugin_sysstat/src/main/disk_usage.rs b/plugins/plugin_sysstat/src/main/disk_usage.rs
index 073375c8..df49d971 100644
--- a/plugins/plugin_sysstat/src/main/disk_usage.rs
+++ b/plugins/plugin_sysstat/src/main/disk_usage.rs
@@ -62,7 +62,7 @@ pub async fn main_disk_usage(state: Arc<Mutex<DiskUsageState>>) -> Result<(), Pl
.deref()
.sys
.disks()
- .into_iter()
+ .iter()
.map(|disk| measure_to_message(disk).map(|msg| lock.send_to.send_and_wait(msg)))
.collect::<Result<Vec<_>, PluginError>>()?;
@@ -124,5 +124,5 @@ fn measure_to_message(disk: &sysinfo::Disk) -> Result<Measurement, PluginError>
MeasurementValue::Bool(disk_removable),
);
let value = MeasurementValue::Map(hm);
- Ok(Measurement::new(disk_name.to_string(), value))
+ Ok(Measurement::new(disk_name, value))
}
diff --git a/plugins/plugin_sysstat/src/main/load.rs b/plugins/plugin_sysstat/src/main/load.rs
index c5821527..16a5b297 100644
--- a/plugins/plugin_sysstat/src/main/load.rs
+++ b/plugins/plugin_sysstat/src/main/load.rs
@@ -64,7 +64,7 @@ pub async fn main_load(state: Arc<Mutex<LoadState>>) -> Result<(), PluginError>
MeasurementValue::Float(load.fifteen),
);
let value = MeasurementValue::Map(hm);
- Measurement::new("load".to_string(), value.clone())
+ Measurement::new("load".to_string(), value)
};
state
diff --git a/plugins/plugin_sysstat/src/main/network.rs b/plugins/plugin_sysstat/src/main/network.rs
index 943206d2..7aa453b7 100644
--- a/plugins/plugin_sysstat/src/main/network.rs
+++ b/plugins/plugin_sysstat/src/main/network.rs
@@ -68,9 +68,7 @@ pub async fn main_network(state: Arc<Mutex<NetworkState>>) -> Result<(), PluginE
.sys
.networks()
.into_iter()
- .filter(|(name, _)| {
- state.all_networks.enable || state.by_name.keys().find(|n| n == name).is_some()
- })
+ .filter(|(name, _)| state.all_networks.enable || state.by_name.keys().any(|n| n == *name))
.map(|(name, network)| {
let config = if state.all_networks.enable {
&state.all_networks.config
diff --git a/plugins/plugin_sysstat/src/main/process.rs b/plugins/plugin_sysstat/src/main/process.rs
index 2b45ae07..92a9410d 100644
--- a/plugins/plugin_sysstat/src/main/process.rs
+++ b/plugins/plugin_sysstat/src/main/process.rs
@@ -57,13 +57,12 @@ impl StateFromConfig for ProcessState {
} else {
pr
};
- let pr = if config.all_processes.config.disk_usage {
+
+ if config.all_processes.config.disk_usage {
pr.with_disk_usage()
} else {
pr
- };
-
- pr
+ }
})
}),
@@ -88,10 +87,9 @@ pub async fn main_process(state: Arc<Mutex<ProcessState>>) -> Result<(), PluginE
|| state
.by_name
.keys()
- .find(|name| *name == process.name())
- .is_some()
+ .any(|name| *name == process.name())
})
- .map(|(_pid, process)| get_measurement(&state, process))
+ .map(|(_pid, process)| get_measurement(state, process))
.map(|value| Measurement::new("processes".to_string(), value))
.collect::<Vec<_>>();
diff --git a/tedge/src/config.rs b/tedge/src/config.rs
index c6250ef9..f9c5b9cf 100644
--- a/tedge/src/config.rs
+++ b/tedge/src/config.rs
@@ -41,7 +41,7 @@ pub fn as_terminal_doc<'a>(desc: &'a ConfigDescription, arena: &'a Arena<'a>) ->
let render_markdown = |text: &str| {
let rendered = skin.text(text, None).to_string();
arena.intersperse(
- rendered.split("\n").map(|t| {
+ rendered.split('\n').map(|t| {
arena.intersperse(
t.split(char::is_whitespace).map(|t| t.to_string()),
arena.softline(),
@@ -52,7 +52,7 @@ pub fn as_terminal_doc<'a>(desc: &'a ConfigDescription, arena: &'a Arena<'a>) ->
};
if let Some(conf_doc) = desc.doc() {
- doc = doc.append(render_markdown(&conf_doc));
+ doc = doc.append(render_markdown(conf_doc));
}
match desc.kind() {
@@ -67,7 +67,7 @@ pub fn as_terminal_doc<'a>(desc: &'a ConfigDescription, arena: &'a Arena<'a>) ->
let mut doc = arena.nil();
if let Some(member_doc) = member_doc {
- doc = doc.append(render_markdown(&member_doc));
+ doc = doc.append(render_markdown(member_doc));
}
doc.append(arena.text(Color::Blue.bold().paint(*member_name).to_string()))
.append(": ")
@@ -123,7 +123,7 @@ pub fn as_terminal_doc<'a>(desc: &'a ConfigDescription, arena: &'a Arena<'a>) ->
.append(": ");
if let Some(member_doc) = member_doc {
- doc = doc.append(render_markdown(&member_doc));
+ doc = doc.append(render_markdown(member_doc));
}
doc.append(
diff --git a/tedge/src/logging.rs b/tedge/src/logging.rs
index 3b4fd837..a2d60e76 100644
--- a/tedge/src/logging.rs
+++ b/tedge/src/logging.rs
@@ -59,13 +59,9 @@ pub fn setup_logging(
.map(|(layer, guard)| (Some(layer), Some(guard)))
.unwrap_or_default();
- let opt_tracy_layer = tracy_logging.then(|| tracing_tracy::TracyLayer::new());
+ let opt_tracy_layer = tracy_logging.then(tracing_tracy::TracyLayer::new);
- let stdout_log = if let Some(env_filter) = env_filter {
- Some(tracing_subscriber::fmt::layer().with_filter(env_filter))
- } else {
- None
- };
+ let stdout_log = env_filter.map(|f| tracing_subscriber::fmt::layer().with_filter(f));
let subscriber = tracing_subscriber::registry::Registry::default()
.with(opt_chrome_layer)
diff --git a/tedge/src/main.rs b/tedge/src/main.rs
index 58b4ef68..f6c50a02 100644
--- a/tedge/src/main.rs
+++ b/tedge/src/main.rs
@@ -18,7 +18,7 @@ async fn main() -> miette::Result<()> {
info!("Tedge booting...");
debug!(?args, "Tedge CLI");
- let registry = tedge_cli::Registry::new();
+ let registry = tedge_cli::Registry::default();
info!("Building application");
let registry = {
@@ -29,7 +29,7 @@ async fn main() -> miette::Result<()> {
register on registry
builder of type plugin_log::LogPluginBuilder<(Measurement, Notification)>,
with instance {
- plugin_log::LogPluginBuilder::<(Measurement, Notification)>::new()
+ plugin_log::LogPluginBuilder::<(Measurement, Notification)>::default()
}
)
},
diff --git a/tedge/src/registry.rs b/tedge/src/registry.rs
index 5db4da45..2986661e 100644
--- a/tedge/src/registry.rs
+++ b/tedge/src/registry.rs
@@ -10,8 +10,8 @@ pub struct Registry {
pub doc_printers: HashMap<String, Box<dyn FnOnce() -> Result<(), miette::Error>>>,
}
-impl Registry {
- pub fn new() -> Self {
+impl Default for Registry {
+ fn default() -> Self {
Registry {
app_builder: tedge_core::TedgeApplication::builder(),
plugin_kinds: HashSet::new(),