-
Notifications
You must be signed in to change notification settings - Fork 19
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
Drop syn proc & quote dep & other id128 refactor #79
Conversation
} | ||
} | ||
|
||
/// Return this machine unique ID. | ||
#[deprecated(since = "0.3.2", note = "use Id128::from_machine()")] |
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.
This looks like an arbitrary/cosmetic rename. If so, let's not do that. The current naming may look ugly, but it is meant to stick closer to the C sd_id128_*
APIs.
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 current naming may look ugly, but it is meant to stick closer to the C
sd_id128_*
APIs.
Yeah that was my understanding reading the code too. It's just that the C API is... for C so since this is a Rust lib it should follow rust API guidelines. Keeping C API is confusing
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.
True... to a certain extent. Keeping some alignment on the names helps a lot with discoverability, that's what I've see from other people/consumers using it.
My rule of thumb is roughly to keep (very similar / identical) names for things that are basically 1:1 ports, and exercise a bit more freedom for things that do not fall in that bucket. Here the former applies though.
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.
Then we can keep the name (get_machine()
) but still stick it onto the Id128
struct. By not having free functions we can in 0.4 hide the id128 module and just reexport the Id128
struct. API ref
0.3: libsystemd::id128::get_machine()
0.4 libsystemd::Id128::get_machine()
Looking at https://github.com/coreos/zincati/blob/10a9c409013364697146ff5bf43c8bdaede347ae/src/identity/mod.rs having the id128
module makes the code much uglier than if all the functions were on the Id128
struct.
Thanks for the PR. I think it is generally nice, but at the same time I think it got a bit out of hand and dragged in a lot of misc stuff. |
} | ||
|
||
/// Return the unique boot ID. | ||
pub fn from_boot() -> Result<Self, SdError> { |
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.
As much as we may not like the original name, this is a port of sd_id128_get_boot(3)
so it would be better to align the naming on that.
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.
Calling it get_boot
would diverge from the Rust method naming scheme. It could just be called boot
instead, but from_boot
is what the systemd crate named it.
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.
Indeed that's unfortunate, naming things is hard and aligning multiple beasts even harder. We cowardly refuse to walk into the minefield here and just go with that upstream has, see other comment for the rationale.
derive
feature from serde & manually impl Error instead of with thiserrortry_from_slice
in favour ofTryFrom<[u8]>
parse_str
in favor ofFromStr
Id128::from_boot
methodget_machine
in favor ofId128::from_machine
get_machine_app_specific
since it goes against the rust API guidelines (users should callId128::from_machine()?.app_specific()
instead)as_bytes
methodAsRef<[u8]>
,,AsRef<OsStr>
From<[u8; 16]>
,Copy
,Default
&Hash
^x.y.z
tox.y.z
as cargo interprets them the sameThis PR is to the best of my knowledge backwards compatible
Closes #78