Skip to content

Commit b9fea1b

Browse files
committed
Use OperationType::name instead of OperationType::to_string()
In order to better convey the intent. Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
1 parent a7b50e8 commit b9fea1b

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

crates/core/tedge_agent/src/operation_workflows/persist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ impl WorkflowRepository {
402402
operation: &OperationType,
403403
command_state: GenericCommandState,
404404
) -> Result<Option<GenericCommandState>, WorkflowExecutionError> {
405-
let operation_name = operation.to_string();
405+
let operation_name = operation.name();
406406
if command_state.is_init() {
407407
// A new command instance must use the latest on-disk version of the operation workflow
408408
self.load_latest_version(&operation_name).await;

crates/core/tedge_api/src/mqtt_topics.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -737,12 +737,6 @@ impl<'a> From<&'a str> for OperationType {
737737
}
738738
}
739739

740-
impl From<&OperationType> for String {
741-
fn from(value: &OperationType) -> Self {
742-
format!("{value}")
743-
}
744-
}
745-
746740
impl Display for OperationType {
747741
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
748742
match self {
@@ -760,6 +754,12 @@ impl Display for OperationType {
760754
}
761755
}
762756

757+
impl OperationType {
758+
pub fn name(&self) -> String {
759+
format!("{self}")
760+
}
761+
}
762+
763763
#[derive(Debug, thiserror::Error, PartialEq, Eq, Clone)]
764764
pub enum ChannelError {
765765
#[error("Channel needs to have at least 2 segments")]

crates/core/tedge_api/src/workflow/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ impl OperationWorkflow {
342342
self.states
343343
.get(&command_state.status)
344344
.ok_or_else(|| WorkflowExecutionError::UnknownStep {
345-
operation: (&self.operation).into(),
345+
operation: self.operation.name(),
346346
step: command_state.status.clone(),
347347
})
348348
.map(|action| action.inject_state(command_state))

0 commit comments

Comments
 (0)