]> git.proxmox.com Git - rustc.git/blame - vendor/rustix/src/termios/constants.rs
New upstream version 1.71.1+dfsg1
[rustc.git] / vendor / rustix / src / termios / constants.rs
CommitLineData
487cf647 1use crate::backend;
353b0b11
FG
2
3pub use backend::termios::types::*;
064997fb
FG
4
5/// Translate from a `Speed` code to a speed value `u32`.
6///
353b0b11 7/// ```
064997fb
FG
8/// let speed = rustix::termios::speed_value(rustix::termios::B57600);
9/// assert_eq!(speed, Some(57600));
10/// ```
487cf647 11pub fn speed_value(speed: backend::termios::types::Speed) -> Option<u32> {
064997fb 12 match speed {
487cf647
FG
13 backend::termios::types::B0 => Some(0),
14 backend::termios::types::B50 => Some(50),
15 backend::termios::types::B75 => Some(75),
16 backend::termios::types::B110 => Some(110),
17 backend::termios::types::B134 => Some(134),
18 backend::termios::types::B150 => Some(150),
19 backend::termios::types::B200 => Some(200),
20 backend::termios::types::B300 => Some(300),
21 backend::termios::types::B600 => Some(600),
22 backend::termios::types::B1200 => Some(1200),
23 backend::termios::types::B1800 => Some(1800),
24 backend::termios::types::B2400 => Some(2400),
25 backend::termios::types::B4800 => Some(4800),
26 backend::termios::types::B9600 => Some(9600),
27 backend::termios::types::B19200 => Some(19200),
28 backend::termios::types::B38400 => Some(38400),
353b0b11 29 #[cfg(not(target_os = "aix"))]
487cf647 30 backend::termios::types::B57600 => Some(57600),
353b0b11 31 #[cfg(not(target_os = "aix"))]
487cf647 32 backend::termios::types::B115200 => Some(115_200),
353b0b11 33 #[cfg(not(target_os = "aix"))]
487cf647
FG
34 backend::termios::types::B230400 => Some(230_400),
35 #[cfg(not(any(
353b0b11
FG
36 apple,
37 target_os = "aix",
487cf647
FG
38 target_os = "dragonfly",
39 target_os = "haiku",
487cf647
FG
40 target_os = "openbsd"
41 )))]
42 backend::termios::types::B460800 => Some(460_800),
353b0b11 43 #[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))]
487cf647 44 backend::termios::types::B500000 => Some(500_000),
353b0b11 45 #[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))]
487cf647
FG
46 backend::termios::types::B576000 => Some(576_000),
47 #[cfg(not(any(
353b0b11
FG
48 apple,
49 target_os = "aix",
487cf647
FG
50 target_os = "dragonfly",
51 target_os = "haiku",
487cf647 52 target_os = "openbsd"
064997fb 53 )))]
487cf647 54 backend::termios::types::B921600 => Some(921_600),
353b0b11 55 #[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))]
487cf647 56 backend::termios::types::B1000000 => Some(1_000_000),
353b0b11 57 #[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))]
487cf647 58 backend::termios::types::B1152000 => Some(1_152_000),
353b0b11 59 #[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))]
487cf647 60 backend::termios::types::B1500000 => Some(1_500_000),
353b0b11 61 #[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))]
487cf647 62 backend::termios::types::B2000000 => Some(2_000_000),
064997fb 63 #[cfg(not(any(
487cf647
FG
64 target_arch = "sparc",
65 target_arch = "sparc64",
353b0b11
FG
66 bsd,
67 target_os = "aix",
487cf647 68 target_os = "haiku",
487cf647 69 target_os = "solaris",
064997fb 70 )))]
487cf647 71 backend::termios::types::B2500000 => Some(2_500_000),
064997fb 72 #[cfg(not(any(
487cf647
FG
73 target_arch = "sparc",
74 target_arch = "sparc64",
353b0b11
FG
75 bsd,
76 target_os = "aix",
487cf647 77 target_os = "haiku",
487cf647 78 target_os = "solaris",
064997fb 79 )))]
487cf647 80 backend::termios::types::B3000000 => Some(3_000_000),
064997fb 81 #[cfg(not(any(
487cf647
FG
82 target_arch = "sparc",
83 target_arch = "sparc64",
353b0b11
FG
84 bsd,
85 target_os = "aix",
487cf647 86 target_os = "haiku",
487cf647 87 target_os = "solaris",
064997fb 88 )))]
487cf647 89 backend::termios::types::B3500000 => Some(3_500_000),
064997fb 90 #[cfg(not(any(
487cf647
FG
91 target_arch = "sparc",
92 target_arch = "sparc64",
353b0b11
FG
93 bsd,
94 target_os = "aix",
487cf647 95 target_os = "haiku",
487cf647 96 target_os = "solaris",
064997fb 97 )))]
487cf647 98 backend::termios::types::B4000000 => Some(4_000_000),
064997fb
FG
99 _ => None,
100 }
101}