-
Notifications
You must be signed in to change notification settings - Fork 11
Implement From<u32> for FwVersion #28
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,16 @@ impl From<FwVersion> for u32 { | |
| } | ||
| } | ||
|
|
||
| impl From<u32> for FwVersion { | ||
| fn from(ver: u32) -> Self { | ||
| Self { | ||
| variant: (ver & 0xFF) as u8, | ||
| minor: ((ver >> 8) & 0xFFFF) as u16, | ||
| major: ((ver >> 24) & 0xFF) as u8, | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+43
to
+51
|
||
|
|
||
| #[derive(Copy, Clone, Debug, PartialEq, Eq)] | ||
| #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| /// LSB first Representation of GetFwVersionResponse | ||
|
|
||
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.
The From implementation duplicates the existing FwVersion::new() method (lines 28-34). Consider deprecating FwVersion::new() in favor of using From::from() consistently throughout the codebase, or remove this From implementation if FwVersion::new() is preferred. Having both can lead to inconsistency in how FwVersion instances are created from u32 values.
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.
Why do we need this? Can't we just call
new()?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.
@jerrysxie Was used from ADO side, not need for now, close this PR.