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 @@ -50,6 +50,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
5050 (#[ 1531] ( https://github.com/nix-rust/nix/pull/1531 ) )
5151- Added ` MAP_ANONYMOUS ` for all operating systems.
5252 (#[ 1534] ( https://github.com/nix-rust/nix/pull/1534 ) )
53+ - Added read/write accessors for 'events' on ` PollFd ` .
54+ (#[ 1517] ( https://github.com/nix-rust/nix/pull/1517 ) )
5355
5456### Changed
5557
Original file line number Diff line number Diff line change @@ -35,10 +35,21 @@ impl PollFd {
3535 }
3636 }
3737
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.
3940 pub fn revents ( self ) -> Option < PollFlags > {
4041 PollFlags :: from_bits ( self . pollfd . revents )
4142 }
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+ }
4253}
4354
4455impl AsRawFd for PollFd {
Original file line number Diff line number Diff line change @@ -72,3 +72,11 @@ fn test_pollfd_fd() {
7272 let pfd = PollFd :: new ( 0x1234 , PollFlags :: empty ( ) ) ;
7373 assert_eq ! ( pfd. as_raw_fd( ) , 0x1234 ) ;
7474}
75+
76+ #[ test]
77+ fn test_pollfd_events ( ) {
78+ let mut pfd = PollFd :: new ( -1 , PollFlags :: POLLIN ) ;
79+ assert_eq ! ( pfd. events( ) , PollFlags :: POLLIN ) ;
80+ pfd. set_events ( PollFlags :: POLLOUT ) ;
81+ assert_eq ! ( pfd. events( ) , PollFlags :: POLLOUT ) ;
82+ }
You can’t perform that action at this time.
0 commit comments