diff options
author | Alex Saveau <saveau.alexandre@gmail.com> | 2022-11-06 11:27:08 -0800 |
---|---|---|
committer | Alex Saveau <saveau.alexandre@gmail.com> | 2022-11-06 11:39:09 -0800 |
commit | 17833268cb3269d83766bcdb4d9cbe0e25ebd38e (patch) | |
tree | b86885991e1d8b6f9c610747c2e8c3a3370960cd /src/pty.rs | |
parent | 20df092bd067908fba23e49120eed7ad62f29108 (diff) | |
download | nix-17833268cb3269d83766bcdb4d9cbe0e25ebd38e.zip |
Reformat everything
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
Diffstat (limited to 'src/pty.rs')
-rw-r--r-- | src/pty.rs | 60 |
1 files changed, 30 insertions, 30 deletions
@@ -8,11 +8,11 @@ use std::io; use std::mem; use std::os::unix::prelude::*; +use crate::errno::Errno; use crate::sys::termios::Termios; #[cfg(feature = "process")] use crate::unistd::{ForkResult, Pid}; -use crate::{Result, fcntl, unistd}; -use crate::errno::Errno; +use crate::{fcntl, unistd, Result}; /// Representation of a master/slave pty pair /// @@ -41,7 +41,6 @@ pub struct ForkptyResult { } } - /// Representation of the Master device in a master/slave pty pair /// /// While this datatype is a thin wrapper around `RawFd`, it enforces that the available PTY @@ -159,9 +158,7 @@ pub fn grantpt(fd: &PtyMaster) -> Result<()> { /// ``` #[inline] pub fn posix_openpt(flags: fcntl::OFlag) -> Result<PtyMaster> { - let fd = unsafe { - libc::posix_openpt(flags.bits()) - }; + let fd = unsafe { libc::posix_openpt(flags.bits()) }; if fd < 0 { return Err(Errno::last()); @@ -239,7 +236,6 @@ pub fn unlockpt(fd: &PtyMaster) -> Result<()> { Ok(()) } - /// Create a new pseudoterminal, returning the slave and master file descriptors /// in `OpenptyResult` /// (see [`openpty`](https://man7.org/linux/man-pages/man3/openpty.3.html)). @@ -248,7 +244,15 @@ pub fn unlockpt(fd: &PtyMaster) -> Result<()> { /// the values in `winsize`. If `termios` is not `None`, the pseudoterminal's /// terminal settings of the slave will be set to the values in `termios`. #[inline] -pub fn openpty<'a, 'b, T: Into<Option<&'a Winsize>>, U: Into<Option<&'b Termios>>>(winsize: T, termios: U) -> Result<OpenptyResult> { +pub fn openpty< + 'a, + 'b, + T: Into<Option<&'a Winsize>>, + U: Into<Option<&'b Termios>>, +>( + winsize: T, + termios: U, +) -> Result<OpenptyResult> { use std::ptr; let mut slave = mem::MaybeUninit::<libc::c_int>::uninit(); @@ -267,17 +271,15 @@ pub fn openpty<'a, 'b, T: Into<Option<&'a Winsize>>, U: Into<Option<&'b Termios> ) } } - (None, Some(winsize)) => { - unsafe { - libc::openpty( - master.as_mut_ptr(), - slave.as_mut_ptr(), - ptr::null_mut(), - ptr::null_mut(), - winsize as *const Winsize as *mut _, - ) - } - } + (None, Some(winsize)) => unsafe { + libc::openpty( + master.as_mut_ptr(), + slave.as_mut_ptr(), + ptr::null_mut(), + ptr::null_mut(), + winsize as *const Winsize as *mut _, + ) + }, (Some(termios), None) => { let inner_termios = termios.get_libc_termios(); unsafe { @@ -290,17 +292,15 @@ pub fn openpty<'a, 'b, T: Into<Option<&'a Winsize>>, U: Into<Option<&'b Termios> ) } } - (None, None) => { - unsafe { - libc::openpty( - master.as_mut_ptr(), - slave.as_mut_ptr(), - ptr::null_mut(), - ptr::null_mut(), - ptr::null_mut(), - ) - } - } + (None, None) => unsafe { + libc::openpty( + master.as_mut_ptr(), + slave.as_mut_ptr(), + ptr::null_mut(), + ptr::null_mut(), + ptr::null_mut(), + ) + }, } }; |