-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace FunctionCode
type alias with enum
#236
Conversation
FunctionCode
FunctionCode
type alias into an enum
FunctionCode
type alias into an enumFunctionCode
type alias into an enum
src/frame/mod.rs
Outdated
} | ||
} | ||
|
||
impl From<FunctionCode> for u8 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if we really want this implicit conversion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FunctionCode -> u8: Ok. But what is the public use case?
u8 -> FunctionCode: Not recommended!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FunctionCode -> u8: Ok. But what is the public use case?
None I think, the user only needs to use the enum variant. Thus, I could remove them both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the new
and value
functions be public too then ?
src/frame/mod.rs
Outdated
} | ||
} | ||
|
||
impl From<u8> for FunctionCode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... same here.
The only thing that's missing now is a changelog entry. |
How do you want to handle the release of the Do you push everything on Can I add the My issue is, will other PR for 0.10 be able to access this changes on |
Please cherry-pick the commit from #239 and add an entry for this PR to avoid merge conflicts. The commits will be squashed when we merge this PR afterwards. |
We usually only do trunk based development. If someone needs to maintain a legacy version for an extended period of time they could fork the repo. |
…s defined in Modbus spec
First time doing a cherry-pick. I've first rebased on main and then cherry-picked your commit. Did I do it right ? |
After
Never rebase, only merge main. Otherwise all review comments become dangling. |
FunctionCode
type alias into an enumFunctionCode
type alias with enum
This PR try to improve the usability of the
FunctionCode
type by adding an enum with modbus public function code, as well a custom function code defined by the user.The goal is to reduce code duplication and ease the use of the
FunctionCode
in order to avoid mistakes.It also adds the ability to retrieve the
FunctionCode
associated with aRequest
/Response
.This will be useful in the futur when we try to implement #165 because we need to have access to the type of
Request
we are handling in case of an error in theserver
.I took inspiration from the work in #226 .
This is a Breaking Change as we are updating a Public type.