@@ -23,7 +23,7 @@ bitflags::bitflags! {
2323 /// are not stored anywhere. Many of these can be represented in different ways, for example:
2424 /// `O_NONBLOCK`, `SOCK_NONBLOCK`, `EFD_NONBLOCK`, `GRND_NONBLOCK`, etc, and not all have the
2525 /// same value.
26- pub struct FileFlags : libc:: c_int {
26+ pub struct FileStatus : libc:: c_int {
2727 const NONBLOCK = libc:: O_NONBLOCK ;
2828 const APPEND = libc:: O_APPEND ;
2929 const ASYNC = libc:: O_ASYNC ;
@@ -45,9 +45,9 @@ bitflags::bitflags! {
4545}
4646
4747bitflags:: bitflags! {
48- pub struct FileStatus : libc:: c_int {
48+ pub struct FileState : libc:: c_int {
4949 /// Has been initialized and it is now OK to unblock any plugin waiting
50- /// on a particular status .
50+ /// on a particular state .
5151 const ACTIVE = c:: _Status_STATUS_DESCRIPTOR_ACTIVE;
5252 /// Can be read, i.e. there is data waiting for user.
5353 const READABLE = c:: _Status_STATUS_DESCRIPTOR_READABLE;
@@ -60,21 +60,21 @@ bitflags::bitflags! {
6060 }
6161}
6262
63- impl From < c:: Status > for FileStatus {
63+ impl From < c:: Status > for FileState {
6464 fn from ( status : c:: Status ) -> Self {
6565 // if any unexpected bits were present, then it's an error
6666 Self :: from_bits ( status) . unwrap ( )
6767 }
6868}
6969
70- impl From < FileStatus > for c:: Status {
71- fn from ( status : FileStatus ) -> Self {
72- status . bits ( )
70+ impl From < FileState > for c:: Status {
71+ fn from ( state : FileState ) -> Self {
72+ state . bits ( )
7373 }
7474}
7575
7676#[ derive( Clone , Debug ) ]
77- pub enum NewStatusListenerFilter {
77+ pub enum StateListenerFilter {
7878 Never ,
7979 OffToOn ,
8080 OnToOff ,
@@ -83,9 +83,9 @@ pub enum NewStatusListenerFilter {
8383
8484/// A wrapper for a `*mut c::StatusListener` that increments its ref count when created,
8585/// and decrements when dropped.
86- struct LegacyStatusListener ( SyncSendPointer < c:: StatusListener > ) ;
86+ struct LegacyListener ( SyncSendPointer < c:: StatusListener > ) ;
8787
88- impl LegacyStatusListener {
88+ impl LegacyListener {
8989 fn new ( ptr : * mut c:: StatusListener ) -> Self {
9090 assert ! ( !ptr. is_null( ) ) ;
9191 unsafe { c:: statuslistener_ref ( ptr) } ;
@@ -97,15 +97,15 @@ impl LegacyStatusListener {
9797 }
9898}
9999
100- impl Drop for LegacyStatusListener {
100+ impl Drop for LegacyListener {
101101 fn drop ( & mut self ) {
102102 unsafe { c:: statuslistener_unref ( self . 0 . ptr ( ) ) } ;
103103 }
104104}
105105
106106/// Stores event listener handles so that `c::StatusListener` objects can subscribe to events.
107107struct LegacyListenerHelper {
108- handle_map : std:: collections:: HashMap < usize , Handle < ( FileStatus , FileStatus ) > > ,
108+ handle_map : std:: collections:: HashMap < usize , Handle < ( FileState , FileState ) > > ,
109109}
110110
111111impl LegacyListenerHelper {
@@ -118,7 +118,7 @@ impl LegacyListenerHelper {
118118 fn add_listener (
119119 & mut self ,
120120 ptr : * mut c:: StatusListener ,
121- event_source : & mut EventSource < ( FileStatus , FileStatus ) > ,
121+ event_source : & mut EventSource < ( FileState , FileState ) > ,
122122 ) {
123123 assert ! ( !ptr. is_null( ) ) ;
124124
@@ -128,10 +128,10 @@ impl LegacyListenerHelper {
128128 }
129129
130130 // this will ref the pointer and unref it when the closure is dropped
131- let ptr_wrapper = LegacyStatusListener :: new ( ptr) ;
131+ let ptr_wrapper = LegacyListener :: new ( ptr) ;
132132
133- let handle = event_source. add_listener ( move |( status , changed) , _event_queue| unsafe {
134- c:: statuslistener_onStatusChanged ( ptr_wrapper. ptr ( ) , status . into ( ) , changed. into ( ) )
133+ let handle = event_source. add_listener ( move |( state , changed) , _event_queue| unsafe {
134+ c:: statuslistener_onStatusChanged ( ptr_wrapper. ptr ( ) , state . into ( ) , changed. into ( ) )
135135 } ) ;
136136
137137 // use a usize as the key so we don't accidentally deref the pointer
@@ -144,14 +144,14 @@ impl LegacyListenerHelper {
144144 }
145145}
146146
147- /// A specified event source that passes a status and the changed bits to the function, but only if
147+ /// A specified event source that passes a state and the changed bits to the function, but only if
148148/// the monitored bits have changed and if the change the filter is satisfied.
149- struct StatusEventSource {
150- inner : EventSource < ( FileStatus , FileStatus ) > ,
149+ struct StateEventSource {
150+ inner : EventSource < ( FileState , FileState ) > ,
151151 legacy_helper : LegacyListenerHelper ,
152152}
153153
154- impl StatusEventSource {
154+ impl StateEventSource {
155155 pub fn new ( ) -> Self {
156156 Self {
157157 inner : EventSource :: new ( ) ,
@@ -161,33 +161,33 @@ impl StatusEventSource {
161161
162162 pub fn add_listener (
163163 & mut self ,
164- monitoring : FileStatus ,
165- filter : NewStatusListenerFilter ,
166- notify_fn : impl Fn ( FileStatus , FileStatus , & mut EventQueue ) + Send + Sync + ' static ,
167- ) -> Handle < ( FileStatus , FileStatus ) > {
164+ monitoring : FileState ,
165+ filter : StateListenerFilter ,
166+ notify_fn : impl Fn ( FileState , FileState , & mut EventQueue ) + Send + Sync + ' static ,
167+ ) -> Handle < ( FileState , FileState ) > {
168168 self . inner
169- . add_listener ( move |( status , changed) , event_queue| {
169+ . add_listener ( move |( state , changed) , event_queue| {
170170 // true if any of the bits we're monitoring have changed
171171 let flipped = monitoring. intersects ( changed) ;
172172
173173 // true if any of the bits we're monitoring are set
174- let on = monitoring. intersects ( status ) ;
174+ let on = monitoring. intersects ( state ) ;
175175
176176 let notify = match filter {
177177 // at least one monitored bit is on, and at least one has changed
178- NewStatusListenerFilter :: OffToOn => flipped && on,
178+ StateListenerFilter :: OffToOn => flipped && on,
179179 // all monitored bits are off, and at least one has changed
180- NewStatusListenerFilter :: OnToOff => flipped && !on,
180+ StateListenerFilter :: OnToOff => flipped && !on,
181181 // at least one monitored bit has changed
182- NewStatusListenerFilter :: Always => flipped,
183- NewStatusListenerFilter :: Never => false ,
182+ StateListenerFilter :: Always => flipped,
183+ StateListenerFilter :: Never => false ,
184184 } ;
185185
186186 if !notify {
187187 return ;
188188 }
189189
190- ( notify_fn) ( status , changed, event_queue)
190+ ( notify_fn) ( state , changed, event_queue)
191191 } )
192192 }
193193
@@ -201,11 +201,11 @@ impl StatusEventSource {
201201
202202 pub fn notify_listeners (
203203 & mut self ,
204- status : FileStatus ,
205- changed : FileStatus ,
204+ state : FileState ,
205+ changed : FileState ,
206206 event_queue : & mut EventQueue ,
207207 ) {
208- self . inner . notify_listeners ( ( status , changed) , event_queue)
208+ self . inner . notify_listeners ( ( state , changed) , event_queue)
209209 }
210210}
211211
@@ -260,9 +260,9 @@ impl std::fmt::Debug for PosixFile {
260260 if let Ok ( file) = self . try_borrow ( ) {
261261 write ! (
262262 f,
263- "(status : {:?}, flags : {:?})" ,
264- file. status ( ) ,
265- file. get_flags ( )
263+ "(state : {:?}, status : {:?})" ,
264+ file. state ( ) ,
265+ file. get_status ( )
266266 )
267267 } else {
268268 write ! ( f, "(already borrowed)" )
@@ -280,25 +280,25 @@ pub enum PosixFileRefMut<'a> {
280280
281281impl PosixFileRef < ' _ > {
282282 enum_passthrough ! ( self , ( ) , Pipe ;
283- pub fn status ( & self ) -> FileStatus
283+ pub fn state ( & self ) -> FileState
284284 ) ;
285285 enum_passthrough ! ( self , ( ) , Pipe ;
286- pub fn get_flags ( & self ) -> FileFlags
286+ pub fn get_status ( & self ) -> FileStatus
287287 ) ;
288288}
289289
290290impl PosixFileRefMut < ' _ > {
291291 enum_passthrough ! ( self , ( ) , Pipe ;
292- pub fn status ( & self ) -> FileStatus
292+ pub fn state ( & self ) -> FileState
293293 ) ;
294294 enum_passthrough ! ( self , ( ) , Pipe ;
295- pub fn get_flags ( & self ) -> FileFlags
295+ pub fn get_status ( & self ) -> FileStatus
296296 ) ;
297297 enum_passthrough ! ( self , ( event_queue) , Pipe ;
298298 pub fn close( & mut self , event_queue: & mut EventQueue ) -> SyscallResult
299299 ) ;
300- enum_passthrough ! ( self , ( flags ) , Pipe ;
301- pub fn set_flags ( & mut self , flags : FileFlags )
300+ enum_passthrough ! ( self , ( status ) , Pipe ;
301+ pub fn set_status ( & mut self , status : FileStatus )
302302 ) ;
303303 enum_passthrough ! ( self , ( ptr) , Pipe ;
304304 pub fn add_legacy_listener( & mut self , ptr: * mut c:: StatusListener )
@@ -326,9 +326,9 @@ impl std::fmt::Debug for PosixFileRef<'_> {
326326
327327 write ! (
328328 f,
329- "(status : {:?}, flags : {:?})" ,
330- self . status ( ) ,
331- self . get_flags ( )
329+ "(state : {:?}, status : {:?})" ,
330+ self . state ( ) ,
331+ self . get_status ( )
332332 )
333333 }
334334}
@@ -341,9 +341,9 @@ impl std::fmt::Debug for PosixFileRefMut<'_> {
341341
342342 write ! (
343343 f,
344- "(status : {:?}, flags : {:?})" ,
345- self . status ( ) ,
346- self . get_flags ( )
344+ "(state : {:?}, status : {:?})" ,
345+ self . state ( ) ,
346+ self . get_status ( )
347347 )
348348 }
349349}
@@ -560,15 +560,15 @@ mod export {
560560 unsafe { Box :: from_raw ( file as * mut PosixFile ) } ;
561561 }
562562
563- /// Get the status of the posix file object.
563+ /// Get the state of the posix file object.
564564 #[ allow( unused_variables) ]
565565 #[ no_mangle]
566566 pub extern "C" fn posixfile_getStatus ( file : * const PosixFile ) -> c:: Status {
567567 assert ! ( !file. is_null( ) ) ;
568568
569569 let file = unsafe { & * file } ;
570570
571- file. borrow ( ) . status ( ) . into ( )
571+ file. borrow ( ) . state ( ) . into ( )
572572 }
573573
574574 /// Add a status listener to the posix file object. This will increment the status
0 commit comments