File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
36
36
(#[ 1511] ( https://github.com/nix-rust/nix/pull/1511 ) )
37
37
- Added ` Ipv4RecvErr ` and ` Ipv6RecvErr ` sockopts and associated control messages.
38
38
(#[ 1514] ( https://github.com/nix-rust/nix/pull/1514 ) )
39
+ - Added read/write accessors for 'events' on ` PollFd ` .
40
+ (#[ 1517] ( https://github.com/nix-rust/nix/pull/1517 ) )
39
41
40
42
### Changed
41
43
Original file line number Diff line number Diff line change @@ -35,10 +35,21 @@ impl PollFd {
35
35
}
36
36
}
37
37
38
- /// Returns the events that occured in the last call to `poll` or `ppoll`.
38
+ /// Returns the events that occured in the last call to `poll` or `ppoll`. Will only return
39
+ /// `None` if the kernel provides status flags that Nix does not know about.
39
40
pub fn revents ( self ) -> Option < PollFlags > {
40
41
PollFlags :: from_bits ( self . pollfd . revents )
41
42
}
43
+
44
+ /// The events of interest for this `PollFd`.
45
+ pub fn events ( self ) -> PollFlags {
46
+ PollFlags :: from_bits ( self . pollfd . events ) . unwrap ( )
47
+ }
48
+
49
+ /// Modify the events of interest for this `PollFd`.
50
+ pub fn set_events ( & mut self , events : PollFlags ) {
51
+ self . pollfd . events = events. bits ( ) ;
52
+ }
42
53
}
43
54
44
55
libc_bitflags ! {
Original file line number Diff line number Diff line change @@ -64,3 +64,11 @@ fn test_ppoll() {
64
64
assert_eq ! ( nfds, 1 ) ;
65
65
assert ! ( fds[ 0 ] . revents( ) . unwrap( ) . contains( PollFlags :: POLLIN ) ) ;
66
66
}
67
+
68
+ #[ test]
69
+ fn test_pollfd_events ( ) {
70
+ let mut pfd = PollFd :: new ( -1 , PollFlags :: POLLIN ) ;
71
+ assert_eq ! ( pfd. events( ) , PollFlags :: POLLIN ) ;
72
+ pfd. set_events ( PollFlags :: POLLOUT ) ;
73
+ assert_eq ! ( pfd. events( ) , PollFlags :: POLLOUT ) ;
74
+ }
You can’t perform that action at this time.
0 commit comments