MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / show

Function show

examples/stdio.rs:38–340  ·  view source on GitHub ↗
(fd: Fd)

Source from the content-addressed store, hash-verified

36
37#[cfg(all(not(windows), feature = "stdio"))]
38fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
39 let fd = fd.as_fd();
40
41 #[cfg(not(target_os = "espidf"))]
42 println!(" - ready bytes: {:?}", rustix::io::ioctl_fionread(fd)?);
43
44 #[cfg(feature = "termios")]
45 if isatty(fd) {
46 #[cfg(feature = "alloc")]
47 #[cfg(feature = "fs")]
48 #[cfg(not(target_os = "fuchsia"))]
49 println!(" - ttyname: {}", ttyname(fd, Vec::new())?.to_string_lossy());
50
51 #[cfg(target_os = "wasi")]
52 println!(" - is a tty");
53
54 #[cfg(not(target_os = "wasi"))]
55 println!(" - process group: {:?}", rustix::termios::tcgetpgrp(fd)?);
56
57 #[cfg(not(any(target_os = "espidf", target_os = "wasi")))]
58 println!(" - winsize: {:?}", rustix::termios::tcgetwinsize(fd)?);
59
60 #[cfg(not(any(target_os = "espidf", target_os = "wasi")))]
61 {
62 use rustix::termios::*;
63 let term = tcgetattr(fd)?;
64
65 println!(" - input_speed: {}", term.input_speed());
66 println!(" - output_speed: {}", term.output_speed());
67
68 print!(" - in flags:");
69 if term.input_modes.contains(InputModes::IGNBRK) {
70 print!(" IGNBRK");
71 }
72 if term.input_modes.contains(InputModes::BRKINT) {
73 print!(" BRKINT");
74 }
75 if term.input_modes.contains(InputModes::IGNPAR) {
76 print!(" IGNPAR");
77 }
78 if term.input_modes.contains(InputModes::PARMRK) {
79 print!(" PARMRK");
80 }
81 if term.input_modes.contains(InputModes::INPCK) {
82 print!(" INPCK");
83 }
84 if term.input_modes.contains(InputModes::ISTRIP) {
85 print!(" ISTRIP");
86 }
87 if term.input_modes.contains(InputModes::INLCR) {
88 print!(" INLCR");
89 }
90 if term.input_modes.contains(InputModes::IGNCR) {
91 print!(" IGNCR");
92 }
93 if term.input_modes.contains(InputModes::ICRNL) {
94 print!(" ICRNL");
95 }

Callers 1

mainFunction · 0.85

Calls 4

containsMethod · 0.80
isattyFunction · 0.50
tcgetattrFunction · 0.50
as_fdMethod · 0.45

Tested by

no test coverage detected