use better trait bounds
This commit is contained in:
@@ -60,21 +60,21 @@ enum Prop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::ptr_arg)]
|
#[allow(clippy::ptr_arg)]
|
||||||
fn uda_string_to_tuple(key: &String) -> (&str, &str) {
|
fn uda_string_to_tuple(key: &str) -> (&str, &str) {
|
||||||
if let Some((ns, key)) = key.split_once('.') {
|
if let Some((ns, key)) = key.split_once('.') {
|
||||||
(ns, key)
|
(ns, key)
|
||||||
} else {
|
} else {
|
||||||
("", key.as_ref())
|
("", key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn uda_tuple_to_string(namespace: impl Into<String>, key: impl Into<String>) -> String {
|
fn uda_tuple_to_string(namespace: impl AsRef<str>, key: impl AsRef<str>) -> String {
|
||||||
// TODO: maybe not Into<String>
|
let namespace = namespace.as_ref();
|
||||||
let namespace = namespace.into();
|
let key = key.as_ref();
|
||||||
if namespace.is_empty() {
|
if namespace.is_empty() {
|
||||||
key.into()
|
key.into()
|
||||||
} else {
|
} else {
|
||||||
format!("{}.{}", namespace, key.into())
|
format!("{}.{}", namespace, key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,8 +335,8 @@ impl<'r> TaskMut<'r> {
|
|||||||
/// model.
|
/// model.
|
||||||
pub fn set_uda(
|
pub fn set_uda(
|
||||||
&mut self,
|
&mut self,
|
||||||
namespace: impl Into<String>,
|
namespace: impl AsRef<str>,
|
||||||
key: impl Into<String>,
|
key: impl AsRef<str>,
|
||||||
value: impl Into<String>,
|
value: impl Into<String>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let key = uda_tuple_to_string(namespace, key);
|
let key = uda_tuple_to_string(namespace, key);
|
||||||
@@ -347,8 +347,8 @@ impl<'r> TaskMut<'r> {
|
|||||||
/// model.
|
/// model.
|
||||||
pub fn remove_uda(
|
pub fn remove_uda(
|
||||||
&mut self,
|
&mut self,
|
||||||
namespace: impl Into<String>,
|
namespace: impl AsRef<str>,
|
||||||
key: impl Into<String>,
|
key: impl AsRef<str>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let key = uda_tuple_to_string(namespace, key);
|
let key = uda_tuple_to_string(namespace, key);
|
||||||
self.remove_legacy_uda(key)
|
self.remove_legacy_uda(key)
|
||||||
@@ -388,9 +388,9 @@ impl<'r> TaskMut<'r> {
|
|||||||
if !self.updated_modified {
|
if !self.updated_modified {
|
||||||
let now = format!("{}", Utc::now().timestamp());
|
let now = format!("{}", Utc::now().timestamp());
|
||||||
trace!("task {}: set property modified={:?}", self.task.uuid, now);
|
trace!("task {}: set property modified={:?}", self.task.uuid, now);
|
||||||
self.task.taskmap = self
|
self.task.taskmap =
|
||||||
.replica
|
self.replica
|
||||||
.update_task(self.task.uuid, Prop::Modified.as_ref(), Some(now))?;
|
.update_task(self.task.uuid, Prop::Modified.as_ref(), Some(now))?;
|
||||||
self.updated_modified = true;
|
self.updated_modified = true;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user