pub struct PollFlags(/* private fields */);poll only.Expand description
These flags define the different events that can be monitored by poll and ppoll
Implementations§
Source§impl PollFlags
impl PollFlags
Sourcepub const POLLPRI: PollFlags
pub const POLLPRI: PollFlags
There is some exceptional condition on the file descriptor.
Possibilities include:
- There is out-of-band data on a TCP socket (see tcp(7)).
- A pseudoterminal master in packet mode has seen a state change on the slave (see ioctl_tty(2)).
- A cgroup.events file has been modified (see cgroups(7)).
Sourcepub const POLLOUT: PollFlags
pub const POLLOUT: PollFlags
Writing is now possible, though a write larger that the
available space in a socket or pipe will still block (unless
O_NONBLOCK is set).
Sourcepub const POLLRDNORM: PollFlags
Available on non-Redox only.
pub const POLLRDNORM: PollFlags
Equivalent to POLLIN
Sourcepub const POLLWRNORM: PollFlags
Available on non-Redox only.
pub const POLLWRNORM: PollFlags
Equivalent to POLLOUT
Sourcepub const POLLRDBAND: PollFlags
Available on non-Redox only.
pub const POLLRDBAND: PollFlags
Priority band data can be read (generally unused on Linux).
Sourcepub const POLLWRBAND: PollFlags
Available on non-Redox only.
pub const POLLWRBAND: PollFlags
Priority data may be written.
Sourcepub const POLLERR: PollFlags
pub const POLLERR: PollFlags
Error condition (only returned in
PollFd::revents;
ignored in PollFd::new).
This bit is also set for a file descriptor referring to the
write end of a pipe when the read end has been closed.
Sourcepub const POLLHUP: PollFlags
pub const POLLHUP: PollFlags
Hang up (only returned in PollFd::revents;
ignored in PollFd::new).
Note that when reading from a channel such as a pipe or a stream
socket, this event merely indicates that the peer closed its
end of the channel. Subsequent reads from the channel will
return 0 (end of file) only after all outstanding data in the
channel has been consumed.
Sourcepub const POLLNVAL: PollFlags
pub const POLLNVAL: PollFlags
Invalid request: fd not open (only returned in
PollFd::revents;
ignored in PollFd::new).
Source§impl PollFlags
impl PollFlags
Sourcepub const fn bits(&self) -> i16
pub const fn bits(&self) -> i16
Get the underlying bits value.
The returned value is exactly the bits set in this flags value.
Sourcepub const fn from_bits(bits: i16) -> Option<PollFlags>
pub const fn from_bits(bits: i16) -> Option<PollFlags>
Convert from a bits value.
This method will return None if any unknown bits are set.
Sourcepub const fn from_bits_truncate(bits: i16) -> PollFlags
pub const fn from_bits_truncate(bits: i16) -> PollFlags
Convert from a bits value, unsetting any unknown bits.
Sourcepub const fn from_bits_retain(bits: i16) -> PollFlags
pub const fn from_bits_retain(bits: i16) -> PollFlags
Convert from a bits value exactly.
Sourcepub fn from_name(name: &str) -> Option<PollFlags>
pub fn from_name(name: &str) -> Option<PollFlags>
Get a flags value with the bits of a flag with the given name set.
This method will return None if name is empty or doesn’t
correspond to any named flag.
Sourcepub const fn intersects(&self, other: PollFlags) -> bool
pub const fn intersects(&self, other: PollFlags) -> bool
Whether any set bits in a source flags value are also set in a target flags value.
Examples found in repository?
9fn main() -> std::io::Result<()> {
10 let cec = CecDevice::open("/dev/cec0")?;
11 let capas = cec.get_capas();
12 println!("capas {:?}", capas);
13 cec.set_mode(CecModeInitiator::None, CecModeFollower::Monitor)?;
14
15 loop {
16 let f = cec.poll(
17 PollFlags::POLLIN | PollFlags::POLLRDNORM | PollFlags::POLLPRI,
18 PollTimeout::NONE,
19 )?;
20
21 if f.intersects(PollFlags::POLLPRI) {
22 let evt = cec.get_event()?;
23 println!("evt {:x?}", evt);
24 }
25 if f.contains(PollFlags::POLLIN | PollFlags::POLLRDNORM) {
26 let msg = cec.rec()?;
27
28 if msg.is_ok() {
29 match (msg.initiator(), msg.destination(), msg.opcode()) {
30 (i, d, Some(Ok(o))) => {
31 println!("msg {:?}->{:?} {:?} {:x?}", i, d, o, msg.parameters());
32 }
33 _ => println!("msg {:x?}", msg),
34 }
35 } else {
36 println!("msg {:x?}", msg);
37 }
38 }
39 }
40}Sourcepub const fn contains(&self, other: PollFlags) -> bool
pub const fn contains(&self, other: PollFlags) -> bool
Whether all set bits in a source flags value are also set in a target flags value.
Examples found in repository?
9fn main() -> std::io::Result<()> {
10 let cec = CecDevice::open("/dev/cec0")?;
11 let capas = cec.get_capas();
12 println!("capas {:?}", capas);
13 cec.set_mode(CecModeInitiator::None, CecModeFollower::Monitor)?;
14
15 loop {
16 let f = cec.poll(
17 PollFlags::POLLIN | PollFlags::POLLRDNORM | PollFlags::POLLPRI,
18 PollTimeout::NONE,
19 )?;
20
21 if f.intersects(PollFlags::POLLPRI) {
22 let evt = cec.get_event()?;
23 println!("evt {:x?}", evt);
24 }
25 if f.contains(PollFlags::POLLIN | PollFlags::POLLRDNORM) {
26 let msg = cec.rec()?;
27
28 if msg.is_ok() {
29 match (msg.initiator(), msg.destination(), msg.opcode()) {
30 (i, d, Some(Ok(o))) => {
31 println!("msg {:?}->{:?} {:?} {:x?}", i, d, o, msg.parameters());
32 }
33 _ => println!("msg {:x?}", msg),
34 }
35 } else {
36 println!("msg {:x?}", msg);
37 }
38 }
39 }
40}Sourcepub fn remove(&mut self, other: PollFlags)
pub fn remove(&mut self, other: PollFlags)
The intersection of a source flags value with the complement of a target flags
value (&!).
This method is not equivalent to self & !other when other has unknown bits set.
remove won’t truncate other, but the ! operator will.
Sourcepub fn toggle(&mut self, other: PollFlags)
pub fn toggle(&mut self, other: PollFlags)
The bitwise exclusive-or (^) of the bits in two flags values.
Sourcepub fn set(&mut self, other: PollFlags, value: bool)
pub fn set(&mut self, other: PollFlags, value: bool)
Call insert when value is true or remove when value is false.
Sourcepub const fn intersection(self, other: PollFlags) -> PollFlags
pub const fn intersection(self, other: PollFlags) -> PollFlags
The bitwise and (&) of the bits in two flags values.
Sourcepub const fn union(self, other: PollFlags) -> PollFlags
pub const fn union(self, other: PollFlags) -> PollFlags
The bitwise or (|) of the bits in two flags values.
Sourcepub const fn difference(self, other: PollFlags) -> PollFlags
pub const fn difference(self, other: PollFlags) -> PollFlags
The intersection of a source flags value with the complement of a target flags
value (&!).
This method is not equivalent to self & !other when other has unknown bits set.
difference won’t truncate other, but the ! operator will.
Sourcepub const fn symmetric_difference(self, other: PollFlags) -> PollFlags
pub const fn symmetric_difference(self, other: PollFlags) -> PollFlags
The bitwise exclusive-or (^) of the bits in two flags values.
Sourcepub const fn complement(self) -> PollFlags
pub const fn complement(self) -> PollFlags
The bitwise negation (!) of the bits in a flags value, truncating the result.
Source§impl PollFlags
impl PollFlags
Sourcepub const fn iter(&self) -> Iter<PollFlags>
pub const fn iter(&self) -> Iter<PollFlags>
Yield a set of contained flags values.
Each yielded flags value will correspond to a defined named flag. Any unknown bits will be yielded together as a final flags value.
Sourcepub const fn iter_names(&self) -> IterNames<PollFlags>
pub const fn iter_names(&self) -> IterNames<PollFlags>
Yield a set of contained named flags values.
This method is like iter, except only yields bits in contained named flags.
Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
Trait Implementations§
Source§impl BitAndAssign for PollFlags
impl BitAndAssign for PollFlags
Source§fn bitand_assign(&mut self, other: PollFlags)
fn bitand_assign(&mut self, other: PollFlags)
The bitwise and (&) of the bits in two flags values.
Source§impl BitOrAssign for PollFlags
impl BitOrAssign for PollFlags
Source§fn bitor_assign(&mut self, other: PollFlags)
fn bitor_assign(&mut self, other: PollFlags)
The bitwise or (|) of the bits in two flags values.
Source§impl BitXorAssign for PollFlags
impl BitXorAssign for PollFlags
Source§fn bitxor_assign(&mut self, other: PollFlags)
fn bitxor_assign(&mut self, other: PollFlags)
The bitwise exclusive-or (^) of the bits in two flags values.
Source§impl Extend<PollFlags> for PollFlags
impl Extend<PollFlags> for PollFlags
Source§fn extend<T>(&mut self, iterator: T)where
T: IntoIterator<Item = PollFlags>,
fn extend<T>(&mut self, iterator: T)where
T: IntoIterator<Item = PollFlags>,
The bitwise or (|) of the bits in each flags value.
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Flags for PollFlags
impl Flags for PollFlags
Source§fn from_bits_retain(bits: i16) -> PollFlags
fn from_bits_retain(bits: i16) -> PollFlags
Source§fn contains_unknown_bits(&self) -> bool
fn contains_unknown_bits(&self) -> bool
true if any unknown bits are set.Source§fn from_bits_truncate(bits: Self::Bits) -> Self
fn from_bits_truncate(bits: Self::Bits) -> Self
Source§fn from_name(name: &str) -> Option<Self>
fn from_name(name: &str) -> Option<Self>
Source§fn iter_names(&self) -> IterNames<Self>
fn iter_names(&self) -> IterNames<Self>
Source§fn iter_defined_names() -> IterDefinedNames<Self>
fn iter_defined_names() -> IterDefinedNames<Self>
Self::FLAGS.Source§fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
Source§fn contains(&self, other: Self) -> boolwhere
Self: Sized,
fn contains(&self, other: Self) -> boolwhere
Self: Sized,
Source§fn insert(&mut self, other: Self)where
Self: Sized,
fn insert(&mut self, other: Self)where
Self: Sized,
|) of the bits in two flags values.Source§fn remove(&mut self, other: Self)where
Self: Sized,
fn remove(&mut self, other: Self)where
Self: Sized,
&!). Read moreSource§fn toggle(&mut self, other: Self)where
Self: Sized,
fn toggle(&mut self, other: Self)where
Self: Sized,
^) of the bits in two flags values.Source§fn intersection(self, other: Self) -> Self
fn intersection(self, other: Self) -> Self
&) of the bits in two flags values.Source§fn difference(self, other: Self) -> Self
fn difference(self, other: Self) -> Self
&!). Read moreSource§fn symmetric_difference(self, other: Self) -> Self
fn symmetric_difference(self, other: Self) -> Self
^) of the bits in two flags values.Source§fn complement(self) -> Self
fn complement(self) -> Self
!) of the bits in a flags value, truncating the result.Source§impl FromIterator<PollFlags> for PollFlags
impl FromIterator<PollFlags> for PollFlags
Source§impl IntoIterator for PollFlags
impl IntoIterator for PollFlags
Source§impl Ord for PollFlags
impl Ord for PollFlags
Source§impl PartialOrd for PollFlags
impl PartialOrd for PollFlags
Source§impl Sub for PollFlags
impl Sub for PollFlags
Source§impl SubAssign for PollFlags
impl SubAssign for PollFlags
Source§fn sub_assign(&mut self, other: PollFlags)
fn sub_assign(&mut self, other: PollFlags)
The intersection of a source flags value with the complement of a target flags value (&!).
This method is not equivalent to self & !other when other has unknown bits set.
difference won’t truncate other, but the ! operator will.