MCPcopy Index your code
hub / github.com/RustPython/RustPython / tcgetattr

Function tcgetattr

crates/stdlib/src/termios.rs:173–195  ·  view source on GitHub ↗
(fd: i32, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

171
172 #[pyfunction]
173 fn tcgetattr(fd: i32, vm: &VirtualMachine) -> PyResult<Vec<PyObjectRef>> {
174 let termios = Termios::from_fd(fd).map_err(|e| termios_error(e, vm))?;
175 let noncanon = (termios.c_lflag & termios::ICANON) == 0;
176 let cc = termios
177 .c_cc
178 .iter()
179 .enumerate()
180 .map(|(i, &c)| match i {
181 termios::VMIN | termios::VTIME if noncanon => vm.ctx.new_int(c).into(),
182 _ => vm.ctx.new_bytes(vec![c as _]).into(),
183 })
184 .collect::<Vec<_>>();
185 let out = vec![
186 termios.c_iflag.to_pyobject(vm),
187 termios.c_oflag.to_pyobject(vm),
188 termios.c_cflag.to_pyobject(vm),
189 termios.c_lflag.to_pyobject(vm),
190 termios::cfgetispeed(&termios).to_pyobject(vm),
191 termios::cfgetospeed(&termios).to_pyobject(vm),
192 vm.ctx.new_list(cc).into(),
193 ];
194 Ok(out)
195 }
196
197 #[pyfunction]
198 fn tcsetattr(fd: i32, when: i32, attributes: PyListRef, vm: &VirtualMachine) -> PyResult<()> {

Callers

nothing calls this directly

Calls 5

termios_errorFunction · 0.85
mapMethod · 0.45
iterMethod · 0.45
new_intMethod · 0.45
new_bytesMethod · 0.45

Tested by

no test coverage detected