Skip to content

Commit

Permalink
Use OperationType::name instead of OperationType::to_string()
Browse files Browse the repository at this point in the history
In order to better convey the intent.

Signed-off-by: Didier Wenzek <[email protected]>
  • Loading branch information
didier-wenzek committed Dec 19, 2024
1 parent eecd222 commit 33268b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/core/tedge_agent/src/operation_workflows/persist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ impl WorkflowRepository {
operation: &OperationType,
command_state: GenericCommandState,
) -> Result<Option<GenericCommandState>, WorkflowExecutionError> {
let operation_name = operation.to_string();
let operation_name = operation.name();
if command_state.is_init() {
// A new command instance must use the latest on-disk version of the operation workflow
self.load_latest_version(&operation_name).await;
Expand Down
12 changes: 6 additions & 6 deletions crates/core/tedge_api/src/mqtt_topics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,12 +737,6 @@ impl<'a> From<&'a str> for OperationType {
}
}

impl From<&OperationType> for String {
fn from(value: &OperationType) -> Self {
format!("{value}")
}
}

impl Display for OperationType {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Expand All @@ -760,6 +754,12 @@ impl Display for OperationType {
}
}

impl OperationType {
pub fn name(&self) -> String {
format!("{self}")
}
}

#[derive(Debug, thiserror::Error, PartialEq, Eq, Clone)]
pub enum ChannelError {
#[error("Channel needs to have at least 2 segments")]
Expand Down
2 changes: 1 addition & 1 deletion crates/core/tedge_api/src/workflow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl OperationWorkflow {
self.states
.get(&command_state.status)
.ok_or_else(|| WorkflowExecutionError::UnknownStep {
operation: (&self.operation).into(),
operation: self.operation.name(),
step: command_state.status.clone(),
})
.map(|action| action.inject_state(command_state))
Expand Down

0 comments on commit 33268b9

Please sign in to comment.