Skip to content

Commit

Permalink
Add data() method to kqueue events (#772)
Browse files Browse the repository at this point in the history
* Add data() method to kqueue events

This allows us to get the raw data field out, which is useful for reading
receipt events.

This lets us fully remove libc from polling, see this line:
https://github.com/smol-rs/polling/blob/6d13def8abd73da96d1e73090f490ae0ad36d6bd/src/kqueue.rs#L132

Signed-off-by: John Nunley <dev@notgull.net>

* Return i64 instead of isize

Signed-off-by: John Nunley <dev@notgull.net>

---------

Signed-off-by: John Nunley <dev@notgull.net>
  • Loading branch information
notgull authored Aug 7, 2023
1 parent fecb8a8 commit 3708b64
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/event/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ impl Event {
self.inner.udata as _
}

/// Get the raw data for this event.
pub fn data(&self) -> i64 {
// On some bsds, data is an isize and not an i64
self.inner.data as _
}

/// Get the filter of this event.
pub fn filter(&self) -> EventFilter {
match self.inner.filter as _ {
Expand Down

0 comments on commit 3708b64

Please sign in to comment.