Skip to content
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

Add default implementations for ModbusContext trait as described in h… #39

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Eisverygoodletter
Copy link
Contributor

@Eisverygoodletter Eisverygoodletter commented Jan 1, 2025

This PR adds default implementation for ModbusContext functions. There are a few unresolved issues:

  • How can these default implementations be unit tested?
    • Currently I haven't removed ModbusStorage's original ModbusContext method implementations. This means all of the unit tests run the code in that implementation and not the default implementations. Those implementations might also be slightly faster than the default implementations because more inlining is possible.
    • I have manually tested the new default implementations by commenting out ModbusStorage's method implementations, but that was a manual process.
  • Should the *_f32 custom implementations in ModbusStorage's implementation of ModbusContext be removed?
    • The default implementation in ModbusContext's definition and the implementation for ModbusStorage are identical.
  • Not really an issue but worth a mention: I have added allow(clippy::cast_lossless, clippy::cast_possible_truncation) as attributes to the definition of ModbusContext. This is because some default implementations trigger those clippy warnings about the u16, u8, and usize casts. The same allow attributes are also present on ModbusStorage's implementation, so I don't see them as an issue.

I've made this PR a draft because the three issues above need to be solved/acknowledged before it is ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant