Skip to content

Commit f55dee9

Browse files
authored
feat: expose the inner fd of Kqueue (#2258)
* feat: expose the inner fd of Kqueue * changelog
1 parent c505277 commit f55dee9

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

changelog/2258.added.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Expose the inner fd of `Kqueue` through:
2+
3+
* impl AsFd for Kqueue
4+
* impl From\<Kqueue\> for OwnedFd

src/sys/event.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use libc::{c_int, c_long, intptr_t, time_t, timespec, uintptr_t};
1010
use libc::{c_long, intptr_t, size_t, time_t, timespec, uintptr_t};
1111
use std::convert::TryInto;
1212
use std::mem;
13+
use std::os::fd::{AsFd, BorrowedFd};
1314
use std::os::unix::io::{AsRawFd, FromRawFd, OwnedFd};
1415
use std::ptr;
1516

@@ -29,6 +30,18 @@ pub struct KEvent {
2930
#[derive(Debug)]
3031
pub struct Kqueue(OwnedFd);
3132

33+
impl AsFd for Kqueue {
34+
fn as_fd(&self) -> BorrowedFd<'_> {
35+
self.0.as_fd()
36+
}
37+
}
38+
39+
impl From<Kqueue> for OwnedFd {
40+
fn from(value: Kqueue) -> Self {
41+
value.0
42+
}
43+
}
44+
3245
impl Kqueue {
3346
/// Create a new kernel event queue.
3447
pub fn new() -> Result<Self> {

0 commit comments

Comments
 (0)