pub async fn close(mut self) -> Result<(), Error> {
        if self.mode.is_write() {
            self.flush().await.map_err(Error::Remote)?;
        }

        let mut result = self.cat.wait_with_output().await?;
        if result.status.success() {
            return Ok(());
        }

        // let us try to cobble together a good error for the user
        let err = match String::from_utf8(std::mem::take(&mut result.stderr)) {
            Err(e) => {
                return Err(Error::Remote(io::Error::new(io::ErrorKind::Other, e)));
            }
            Ok(s) => s,
        };
        let err = err.trim();

        if let Some(1) = result.status.code() {
            // looking at cat's source at the time of writing:
            // https://github.com/coreutils/coreutils/blob/730876d067f24380ccec1bdd1f179a664f11aa2f/src/cat.c
            // cat always returns with EXIT_FAILURE, which is 1 on all POSIX platforms.
        } else {
            // something really weird happened.
            return Err(Error::Remote(io::Error::new(io::ErrorKind::Other, err)));
        }

        // search for "die" or EXIT_FAILURE in the cat source code:
        // https://github.com/coreutils/coreutils/blob/master/src/cat.c
        #[allow(clippy::collapsible_if)]
        Err(Error::Remote(if self.mode.is_write() {
            if err.ends_with(": No such file or directory") {
                io::Error::new(io::ErrorKind::NotFound, err)
            } else {
                io::Error::new(io::ErrorKind::WriteZero, err)
            }
        } else if err.ends_with(": No such file or directory") {
            io::Error::new(io::ErrorKind::NotFound, err)
        } else {
            io::Error::new(io::ErrorKind::UnexpectedEof, err)
        }))
    }
/// Close the handle to the remote file.
///
/// If the remote file was opened for reading, this will also call
/// [`flush`](AsyncWriteExt::flush).
///
/// When you close the remote file, any errors on the remote end will also be propagated. This
/// means that you could see errors about remote files not existing, or disks being full, only
/// at the time when you call `close`.
Close the handle to the remote file.
If the remote file was opened for reading, this will also call
[`flush`](AsyncWriteExt::flush).

When you close the remote file, any errors on the remote end will also be propagated. This
means that you could see errors about remote files not existing, or disks being full, only
at the time when you call `close`.
Close the handle to the remote file . If the remote file was opened for reading this will also call [ ` flush ` ] ( AsyncWriteExt :: flush ) . When you close the remote file any errors on the remote end will also be propagated . This means that you could see errors about remote files not existing or disks being full only at the time when you call ` close ` .
pub async fn close(mut self) -> Result<(), Error> {
        if self.mode.is_write() {
            self.flush().await.map_err(Error::Remote)?;
        }
        let mut result = self.cat.wait_with_output().await?;
        if result.status.success() {
            return Ok(());
        }
        // let us try to cobble together a good error for the user
        let err = match String::from_utf8(std::mem::take(&mut result.stderr)) {
            Err(e) => {
                return Err(Error::Remote(io::Error::new(io::ErrorKind::Other, e)));
            }
            Ok(s) => s,
        };
        let err = err.trim();
        if let Some(1) = result.status.code() {
            // looking at cat's source at the time of writing:
            // https://github.com/coreutils/coreutils/blob/730876d067f24380ccec1bdd1f179a664f11aa2f/src/cat.c
            // cat always returns with EXIT_FAILURE, which is 1 on all POSIX platforms.
        } else {
            // something really weird happened.
            return Err(Error::Remote(io::Error::new(io::ErrorKind::Other, err)));
        }
        // search for "die" or EXIT_FAILURE in the cat source code:
        // https://github.com/coreutils/coreutils/blob/master/src/cat.c
        #[allow(clippy::collapsible_if)]
        Err(Error::Remote(if self.mode.is_write() {
            if err.ends_with(": No such file or directory") {
                io::Error::new(io::ErrorKind::NotFound, err)
            } else {
                io::Error::new(io::ErrorKind::WriteZero, err)
            }
        } else if err.ends_with(": No such file or directory") {
            io::Error::new(io::ErrorKind::NotFound, err)
        } else {
            io::Error::new(io::ErrorKind::UnexpectedEof, err)
        }))
    }
pub async fn close ( mut self ) -> Result < ( ) , Error > { if self . mode . is_write ( ) { self . flush ( ) . await . map_err ( Error :: Remote ) ? ; } let mut result = self . cat . wait_with_output ( ) . await ? ; if result . status . success ( ) { return Ok ( ( ) ) ; } // let us try to cobble together a good error for the user let err = match String :: from_utf8 ( std :: mem :: take ( & mut result . stderr ) ) { Err ( e ) => { return Err ( Error :: Remote ( io :: Error :: new ( io :: ErrorKind :: Other , e ) ) ) ; } Ok ( s ) => s , } ; let err = err . trim ( ) ; if let Some ( 1 ) = result . status . code ( ) { // looking at cat's source at the time of writing: // https://github.com/coreutils/coreutils/blob/730876d067f24380ccec1bdd1f179a664f11aa2f/src/cat.c // cat always returns with EXIT_FAILURE, which is 1 on all POSIX platforms. } else { // something really weird happened. return Err ( Error :: Remote ( io :: Error :: new ( io :: ErrorKind :: Other , err ) ) ) ; } // search for "die" or EXIT_FAILURE in the cat source code: // https://github.com/coreutils/coreutils/blob/master/src/cat.c # [ allow ( clippy collapsible_if ) ] Err ( Error :: Remote ( if self . mode . is_write ( ) { if err . ends_with ( " " ) { io :: Error :: new ( io :: ErrorKind :: NotFound , err ) } else { io :: Error :: new ( io :: ErrorKind :: WriteZero , err ) } } else if err . ends_with ( " " ) { io :: Error :: new ( io :: ErrorKind :: NotFound , err ) } else { io :: Error :: new ( io :: ErrorKind :: UnexpectedEof , err ) } ) ) }
Close the handle to the remote file.
Close the handle to the remote file .
mut self
mut self