/// Writes the final padding bytes according to PKCS#7, destroys
/// the encrypting wrapper, and returns the underlying
/// `std::io::Write` object.
Writes the final padding bytes according to PKCS#7, destroys
the encrypting wrapper, and returns the underlying
`std::io::Write` object.
Writes the final padding bytes according to PKCS#7 destroys the encrypting wrapper and returns the underlying ` std :: io :: Write ` object .
pub fn close(mut self) -> io::Result<W> {
        if !try!(self.flush_enc_buf()) {
            return Err(io::Error::new(io::ErrorKind::Other, "couldn't flush encrypted bytes to sink",
                                      Some(format!("sink couldn't write the last {} bytes that were already encoded", self.enc_buf.len()))));
        }
        self.enc_buf.truncate(0);
        let pad_byte = 8 - self.buf.len() as u8;
        self.buf.resize(8, pad_byte);
        let written = try!(self.sink.write(encrypt_chunk(&self.key, &mut self.prev, &self.buf)));
        if written != 8 {
            return Err(io::Error::new(io::ErrorKind::Other, "couldn't write final 8 bytes to sink",
                                      Some(format!("sink only accepted {} bytes, can't close this writer", written))));
        }
        self.buf.truncate(0);
        try!(self.sink.flush());
        Ok(self.sink)
    }
pub fn close ( mut self ) -> io :: Result < W > { if ! try ! ( self flush_enc_buf ( ) ) { return Err ( io :: Error :: new ( io :: ErrorKind :: Other , " " , Some ( format ! ( " " self enc_buf len ( ) ) ) ) ) ; } self . enc_buf . truncate ( 0 ) ; let pad_byte = 8 - self . buf . len ( ) as u8 ; self . buf . resize ( 8 , pad_byte ) ; let written = try ! ( self sink write ( encrypt_chunk ( self key mut self prev self buf ) ) ) ; if written != 8 { return Err ( io :: Error :: new ( io :: ErrorKind :: Other , " " , Some ( format ! ( " " written ) ) ) ) ; } self . buf . truncate ( 0 ) ; try ! ( self sink flush ( ) ) ; Ok ( self . sink ) }
Writes the final padding bytes according to PKCS#7, destroys
the encrypting wrapper, and returns the underlying
`std::io::Write` object.
Writes the final padding bytes according to PKCS#7 destroys the encrypting wrapper and returns the underlying ` std :: io :: Write ` object .
mut self