-
Notifications
You must be signed in to change notification settings - Fork 193
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
Socketevent bitflags macro #353
base: master
Are you sure you want to change the base?
Conversation
HANDSHAKE_SUCCEEDED = zmq_sys::ZMQ_EVENT_HANDSHAKE_SUCCEEDED as isize, | ||
HANDSHAKE_FAILED_PROTOCOL = zmq_sys::ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL as isize, | ||
HANDSHAKE_FAILED_AUTH = zmq_sys::ZMQ_EVENT_HANDSHAKE_FAILED_AUTH as isize, | ||
ALL = zmq_sys::ZMQ_EVENT_ALL as isize, |
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 discussed prior, all()
returns a union of all flags, which for this pair of constants seems to result in (1<<15) - 1
whereas ZMQ_EVENT_ALL
is defined as (1 << 16) - 1
- the highest bit 1<<15
isn't used by a constant yet.
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.
So the suggestion is to probably keep this around - which automatically makes ::all()
return the same value as ALL
even if there's one bit that appears to be "reserved".
This PR replaces the
SocketEvent
struct with a macro call to the (existing)bitflags
crate. Additionally,monitor
's event argument now takes aSocketEvent
rather than the previous raw integer.The docstrings come from the docs and the header file.
Notably, I removed the
SocketEvent::ALL
option in favor ofSocketEvent::all()
, due to two reasons: removing the bitflagsall
function is not possible and by using theall
function, all rust-defined events are passed only, rather than0xFFFF
. The original behaviour is still possible by using:SocketEvent::from_bits_unchecked(0xFFFF)
.An example of the change in this PR (with type annotation), before:
After: