* [pdm-devel] [PATCH proxmox-datacenter-manager 1/4] elide lifetimes in traits when possible
@ 2025-01-13 12:08 Maximiliano Sandoval
2025-01-13 12:08 ` [pdm-devel] [PATCH proxmox-datacenter-manager 2/4] remove needless borrows Maximiliano Sandoval
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 12:08 UTC (permalink / raw)
To: pdm-devel
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
cli/client/src/resources.rs | 2 +-
lib/pdm-config/src/certificate_config.rs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/cli/client/src/resources.rs b/cli/client/src/resources.rs
index 53ee2e0..cbc616a 100644
--- a/cli/client/src/resources.rs
+++ b/cli/client/src/resources.rs
@@ -248,7 +248,7 @@ impl<'a, T: fmt::Display> Formatted<'a, T> {
}
}
-impl<'a, T: fmt::Display> fmt::Display for Formatted<'a, T> {
+impl<T: fmt::Display> fmt::Display for Formatted<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if env().use_color() {
write!(f, "{}{}{}", self.format, self.content, COLOR_RESET)
diff --git a/lib/pdm-config/src/certificate_config.rs b/lib/pdm-config/src/certificate_config.rs
index 0cec037..360cc87 100644
--- a/lib/pdm-config/src/certificate_config.rs
+++ b/lib/pdm-config/src/certificate_config.rs
@@ -123,7 +123,7 @@ impl<'a> AcmeDomainIter<'a> {
}
}
-impl<'a> Iterator for AcmeDomainIter<'a> {
+impl Iterator for AcmeDomainIter<'_> {
type Item = Result<AcmeDomain, Error>;
fn next(&mut self) -> Option<Self::Item> {
--
2.39.5
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pdm-devel] [PATCH proxmox-datacenter-manager 2/4] remove needless borrows
2025-01-13 12:08 [pdm-devel] [PATCH proxmox-datacenter-manager 1/4] elide lifetimes in traits when possible Maximiliano Sandoval
@ 2025-01-13 12:08 ` Maximiliano Sandoval
2025-01-13 12:08 ` [pdm-devel] [PATCH proxmox-datacenter-manager 3/4] task_cache: Do field assigment inside initializer Maximiliano Sandoval
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 12:08 UTC (permalink / raw)
To: pdm-devel
Fixes e.g.
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> server/src/task_cache.rs:45:37
|
45 | let tasks = fetch_tasks(&remote).await?;
| ^^^^^^^ help: change this to: `remote`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
= note: `#[warn(clippy::needless_borrow)]` on by default
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
server/src/api/resources.rs | 6 +++---
server/src/metric_collection/mod.rs | 2 +-
server/src/task_cache.rs | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/server/src/api/resources.rs b/server/src/api/resources.rs
index 376d493..f6438c6 100644
--- a/server/src/api/resources.rs
+++ b/server/src/api/resources.rs
@@ -106,7 +106,7 @@ pub(crate) async fn get_resources_impl(
for (remote_name, remote) in remotes_config {
if let Some(ref auth_id) = opt_auth_id {
- let remote_privs = user_info.lookup_privs(&auth_id, &["resource", &remote_name]);
+ let remote_privs = user_info.lookup_privs(auth_id, &["resource", &remote_name]);
if remote_privs & PRIV_RESOURCE_AUDIT == 0 {
continue;
}
@@ -441,7 +441,7 @@ async fn fetch_remote_subscription_info(
let mut list = HashMap::new();
match remote.ty {
RemoteType::Pve => {
- let client = connection::make_pve_client(&remote)?;
+ let client = connection::make_pve_client(remote)?;
let nodes = client.list_nodes().await?;
let mut futures = Vec::with_capacity(nodes.len());
@@ -471,7 +471,7 @@ async fn fetch_remote_subscription_info(
}
}
RemoteType::Pbs => {
- let client = connection::make_pbs_client(&remote)?;
+ let client = connection::make_pbs_client(remote)?;
let info = client.get_subscription().await.ok().map(|info| {
let level = SubscriptionLevel::from_key(info.key.as_deref());
diff --git a/server/src/metric_collection/mod.rs b/server/src/metric_collection/mod.rs
index c887e1f..b37d678 100644
--- a/server/src/metric_collection/mod.rs
+++ b/server/src/metric_collection/mod.rs
@@ -76,7 +76,7 @@ async fn metric_collection_task() -> Result<(), Error> {
.await
}
RemoteType::Pbs => {
- let client = connection::make_pbs_client(&remote)?;
+ let client = connection::make_pbs_client(remote)?;
let metrics = client.metrics(Some(true), Some(start_time)).await?;
// Involves some blocking file IO
diff --git a/server/src/task_cache.rs b/server/src/task_cache.rs
index dab29fe..2d3c9b6 100644
--- a/server/src/task_cache.rs
+++ b/server/src/task_cache.rs
@@ -42,7 +42,7 @@ pub async fn get_tasks(max_age: i64) -> Result<Vec<TaskListItem>, Error> {
// Data in cache is recent enough and has not been invalidated.
all_tasks.extend(tasks);
} else {
- let tasks = fetch_tasks(&remote).await?;
+ let tasks = fetch_tasks(remote).await?;
cache.set_tasks(remote_name.as_str(), tasks.clone(), now);
all_tasks.extend(tasks);
--
2.39.5
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pdm-devel] [PATCH proxmox-datacenter-manager 3/4] task_cache: Do field assigment inside initializer
2025-01-13 12:08 [pdm-devel] [PATCH proxmox-datacenter-manager 1/4] elide lifetimes in traits when possible Maximiliano Sandoval
2025-01-13 12:08 ` [pdm-devel] [PATCH proxmox-datacenter-manager 2/4] remove needless borrows Maximiliano Sandoval
@ 2025-01-13 12:08 ` Maximiliano Sandoval
2025-01-13 12:08 ` [pdm-devel] [PATCH proxmox-datacenter-manager 4/4] resources: Remove unnecessary closure Maximiliano Sandoval
2025-01-13 12:15 ` [pdm-devel] applied: [PATCH proxmox-datacenter-manager 1/4] elide lifetimes in traits when possible Dietmar Maurer
3 siblings, 0 replies; 5+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 12:08 UTC (permalink / raw)
To: pdm-devel
Fixes:
warning: field assignment outside of initializer for an instance created with Default::default()
--> server/src/task_cache.rs:78:17
|
78 | params.source = Some(ListTasksSource::All);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: consider initializing the variable with `pve_api_types::ListTasks { source: Some(ListTasksSource::All), since: Some(proxmox_time::epoch_i64() - 7 * 24 * 60 * 60), ..Default::default() }` and removing relevant reassignments
--> server/src/task_cache.rs:76:17
|
76 | let mut params = ListTasks::default();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
= note: `#[warn(clippy::field_reassign_with_default)]` on by default
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
server/src/task_cache.rs | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/server/src/task_cache.rs b/server/src/task_cache.rs
index 2d3c9b6..3ef24b1 100644
--- a/server/src/task_cache.rs
+++ b/server/src/task_cache.rs
@@ -73,12 +73,14 @@ async fn fetch_tasks(remote: &Remote) -> Result<Vec<TaskListItem>, Error> {
// N+1 requests - we could use /cluster/tasks, but that one
// only gives a limited task history
for node in client.list_nodes().await? {
- let mut params = ListTasks::default();
- // Include running tasks
- params.source = Some(ListTasksSource::All);
- // TODO: How much task history do we want? Right now we just hard-code it
- // to 7 days.
- params.since = Some(proxmox_time::epoch_i64() - 7 * 24 * 60 * 60);
+ let params = ListTasks {
+ // Include running tasks
+ source: Some(ListTasksSource::All),
+ // TODO: How much task history do we want? Right now we just hard-code it
+ // to 7 days.
+ since: Some(proxmox_time::epoch_i64() - 7 * 24 * 60 * 60),
+ ..Default::default()
+ };
let list = client.get_task_list(&node.node, params).await?;
let mapped = map_tasks(list, &remote.id)?;
--
2.39.5
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pdm-devel] [PATCH proxmox-datacenter-manager 4/4] resources: Remove unnecessary closure
2025-01-13 12:08 [pdm-devel] [PATCH proxmox-datacenter-manager 1/4] elide lifetimes in traits when possible Maximiliano Sandoval
2025-01-13 12:08 ` [pdm-devel] [PATCH proxmox-datacenter-manager 2/4] remove needless borrows Maximiliano Sandoval
2025-01-13 12:08 ` [pdm-devel] [PATCH proxmox-datacenter-manager 3/4] task_cache: Do field assigment inside initializer Maximiliano Sandoval
@ 2025-01-13 12:08 ` Maximiliano Sandoval
2025-01-13 12:15 ` [pdm-devel] applied: [PATCH proxmox-datacenter-manager 1/4] elide lifetimes in traits when possible Dietmar Maurer
3 siblings, 0 replies; 5+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 12:08 UTC (permalink / raw)
To: pdm-devel
warning: unnecessary closure used to substitute value for `Option::None`
--> server/src/api/resources.rs:322:21
|
322 | let timeframe = timeframe.unwrap_or_else(|| RrdTimeframe::Day);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
= note: `#[warn(clippy::unnecessary_lazy_evaluations)]` on by default
help: use `unwrap_or` instead
|
322 | let timeframe = timeframe.unwrap_or(RrdTimeframe::Day);
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
server/src/api/resources.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/server/src/api/resources.rs b/server/src/api/resources.rs
index f6438c6..453d9e8 100644
--- a/server/src/api/resources.rs
+++ b/server/src/api/resources.rs
@@ -319,7 +319,7 @@ pub async fn get_subscription_status(
async fn get_top_entities(timeframe: Option<RrdTimeframe>) -> Result<TopEntities, Error> {
let (remotes_config, _) = pdm_config::remotes::config()?;
- let timeframe = timeframe.unwrap_or_else(|| RrdTimeframe::Day);
+ let timeframe = timeframe.unwrap_or(RrdTimeframe::Day);
let res = crate::metric_collection::calculate_top(&remotes_config.sections, timeframe, 10);
Ok(res)
}
--
2.39.5
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pdm-devel] applied: [PATCH proxmox-datacenter-manager 1/4] elide lifetimes in traits when possible
2025-01-13 12:08 [pdm-devel] [PATCH proxmox-datacenter-manager 1/4] elide lifetimes in traits when possible Maximiliano Sandoval
` (2 preceding siblings ...)
2025-01-13 12:08 ` [pdm-devel] [PATCH proxmox-datacenter-manager 4/4] resources: Remove unnecessary closure Maximiliano Sandoval
@ 2025-01-13 12:15 ` Dietmar Maurer
3 siblings, 0 replies; 5+ messages in thread
From: Dietmar Maurer @ 2025-01-13 12:15 UTC (permalink / raw)
To: Proxmox Datacenter Manager development discussion, Maximiliano Sandoval
applied all 4 patches
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-01-13 12:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-13 12:08 [pdm-devel] [PATCH proxmox-datacenter-manager 1/4] elide lifetimes in traits when possible Maximiliano Sandoval
2025-01-13 12:08 ` [pdm-devel] [PATCH proxmox-datacenter-manager 2/4] remove needless borrows Maximiliano Sandoval
2025-01-13 12:08 ` [pdm-devel] [PATCH proxmox-datacenter-manager 3/4] task_cache: Do field assigment inside initializer Maximiliano Sandoval
2025-01-13 12:08 ` [pdm-devel] [PATCH proxmox-datacenter-manager 4/4] resources: Remove unnecessary closure Maximiliano Sandoval
2025-01-13 12:15 ` [pdm-devel] applied: [PATCH proxmox-datacenter-manager 1/4] elide lifetimes in traits when possible Dietmar Maurer
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.