slowtec / tokio-modbus

A tokio-based modbus library
Apache License 2.0
405 stars 120 forks source link

Replace `FunctionCode` type alias with enum #236

Closed benjamin-nw closed 9 months ago

benjamin-nw commented 9 months ago

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 a Request/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 the server.

I took inspiration from the work in #226 .

This is a Breaking Change as we are updating a Public type.

uklotzde commented 9 months ago

The only thing that's missing now is a changelog entry.

benjamin-nw commented 9 months ago

How do you want to handle the release of the 0.10 version ?

Do you push everything on main until the new version is released ? Or do you have a branch for a new version ?

Can I add the ## 0.10.0 (Unreleased) entry in the Changelog here ?

My issue is, will other PR for 0.10 be able to access this changes on main or another branch ?

uklotzde commented 9 months ago

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.

uklotzde commented 9 months ago

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.

benjamin-nw commented 9 months ago

First time doing a cherry-pick.

I've first rebased on main and then cherry-picked your commit.

Did I do it right ?

uklotzde commented 9 months ago

After

First time doing a cherry-pick.

I've first rebased on main and then cherry-picked your commit.

Did I do it right ?

Never rebase, only merge main. Otherwise all review comments become dangling.