lnicola / sd-notify

Apache License 2.0
43 stars 6 forks source link

SD_LISTEN_FDS_START could maybe be of type RawFd #3

Closed hug-dev closed 3 years ago

hug-dev commented 3 years ago

Hello 👋

Not a big problem at all, but when upgrading our version of this crate the following code threw a compilation error (and that's fine cause it was a breaking change upgrade 😄):

let nfd = sd_notify::SD_LISTEN_FDS_START;
let listener = unsafe { UnixListener::from_raw_fd(nfd) };

If it's common practice (but I am not entirely sure of that) to use SD_LISTEN_FDS_START with the FromRawFd trait, maybe it would make sense to use the type RawFd from stdlib.

Just a question/suggestion!

lnicola commented 3 years ago

See also https://github.com/lnicola/sd-notify/pull/2#issuecomment-781479996. Maybe returning impl Iterator<Item=RawFd> would be a better API?

hug-dev commented 3 years ago

Topical 😃!

Yes I think returning an iterator (or a Vec<RawFd>?) could be nice so then you don't have to do the logic yourself? As in you don't need SD_LISTEN_FDS_START anymore but directly use the RawFds returned