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

Use custom UMessage struct #112

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sophokles73
Copy link
Contributor

The build.rs script no longer pulls in the umessage.proto from up-spec.
Instead, the umessage module no defines the UMessage struct with
private fields so that UMessages can now only be created (correctly) via
the UMessageBuilder.

The build.rs script no longer pulls in the umessage.proto from up-spec.
Instead, the umessage module no defines the UMessage struct with
private fields so that UMessages can now only be created (correctly) via
the UMessageBuilder.
@sophokles73 sophokles73 marked this pull request as draft May 24, 2024 13:36
impl UMessage {
pub fn attributes(&self) -> &UAttributes {
Copy link
Contributor

@PLeVasseur PLeVasseur May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this!

So the idea is that we have now not generated the code for the UMessage .proto object, so we can force correctness, as the only way to build a UMessage is via UMessageBuilder and we've made the struct fields private and can only grab the UAttributes and payload Bytes as reference.

Slick!!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would have been the idea, yes. Sadly, though, UMessage is actually being used by uTwin in its input/output messages, so the initial approach will not work ...

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.

2 participants