refactor: Extract supported_operations module from c8y_api#3277
refactor: Extract supported_operations module from c8y_api#3277Bravo555 merged 2 commits intothin-edge:mainfrom
supported_operations module from c8y_api#3277Conversation
supported_operations module from c8y_apisupported_operations module from c8y_api
Codecov ReportAttention: Patch coverage is Additional details and impacted files📢 Thoughts on this report? Let us know! |
Robot Results
|
didier-wenzek
left a comment
There was a problem hiding this comment.
I'm okay with this refactoring, except that I would have preferred a git mv crates/core/c8y_api/src/smartrest/operations.rs ... rather than a delete and two new files.
It was necessary to make some changes in Despite that, when the first commit is viewed separately, it shows as a rename, so old and new is side by side and you can compare that way. But I can remove the 2nd commit and make it into a separate PR if you'd like. |
No, that's okay. The move in the first commit is what I was looking for. |
albinsuresh
left a comment
There was a problem hiding this comment.
LGTM, except for the odd module placement.
| @@ -0,0 +1,501 @@ | |||
| //! [Supported Operations API] | |||
There was a problem hiding this comment.
I just find the placement of this module a bit weird, as it is placed directly at the root of the crate whereas operations.rs is placed under supported_operations. Would it make sense to move this into a mod.rs under supported_operations?
There was a problem hiding this comment.
This style of module placement was supported for some time, and I think it's better to use than the older style for 2 reasons:
- if you split a submodule off a bigger module, you don't have to move the other file and rename it to
mod.rs, which makes the diffs a bit smaller (bigger pro IMO) - the file name is still a module name, whereas with
mod.rsfor the module name you have to look at the name of the parent directory, but as the editor tab contains only a file name, you can end up with manymod.rsfiles, so it's a bit harder to keep track of (actually in vscode when two files have the same name then it will display a parent in the tab for context)
But as we're already using the older style (we have 38 mod.rs files) I will use this style for consistency.
75b9694 to
cec76d0
Compare
`c8y_api::smartrest::operations` was moved to `c8y_mapper_ext::supported_operations` because: - it deals with loading operation files from the local filesystem, not c8y_api concern - it was inside `smartrest` module, while not having much to do with smartrest (ie. it only generated "114 Set supported operations" message) Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
The `supported_operations` module is divided into 2 parts: - loading, updating, managing the supported operation set, matching on this set, etc. basically managing the collection - new `supported_operations::operation` contains the functions and types related to reading and parsing single operation files from the filesystem Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
cec76d0 to
71a68b1
Compare
rina23q
left a comment
There was a problem hiding this comment.
Thanks a lot for the improvement. I knew that core/c8y_api/src/smartrest had many operation related stuff but unrelated to SmartREST, however, I couldn't change while implementing a feature. It was frustrating. Happy to see that it's now refactored.
Proposed changes
c8y_api::smartrest::operationswas moved toc8y_mapper_ext::supported_operationsbecause:c8y_apiconcernsmartrestmodule, while not having much to do with smartrest (ie. it only generated "114 Set supported operations" message)Additionally the
supported_operationsmodule was divided into 2 parts:supported_operations: loading, updating, managing the supported operation set, matching on this set, generating messages to set, etc. basically managing the collection and interacting withCumulocityConvertersupported_operations::operation: contains the functions and types related to reading and parsing single operation files from the filesystem and field substitutionTypes of changes
Paste Link to the issue
Operationsstruct refactor #3256Checklist
cargo fmtas mentioned in CODING_GUIDELINEScargo clippyas mentioned in CODING_GUIDELINESFurther comments