rust: bssl-tls: Bubble up EOF during shutdown

Application protocol may depend on knowning if the connection shutdown
was graceful and bidirectional.
We will make the status visible as one possible outcome of a shutdown
call.

Signed-off-by: Xiangfei Ding <xfding@google.com>
Change-Id: I1da200d803f04263dbb05b89f5d1bea66a6a6964
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/93527
Reviewed-by: Adam Langley <agl@google.com>
Presubmit-BoringSSL-Verified: boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com <boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/rust/bssl-tls/src/connection/lifecycle.rs b/rust/bssl-tls/src/connection/lifecycle.rs
index edbb6c4..142446f 100644
--- a/rust/bssl-tls/src/connection/lifecycle.rs
+++ b/rust/bssl-tls/src/connection/lifecycle.rs
@@ -252,16 +252,14 @@
             bssl_sys::SSL_shutdown(self.ptr())
         };
         if self.is_write_closed() {
-            return Ok(ShutdownStatus::CloseNotifyReceived);
+            return Ok(ShutdownStatus::EndOfStream);
         }
         match rc {
             0 => Ok(ShutdownStatus::CloseNotifyPosted),
             1 => Ok(ShutdownStatus::CloseNotifyReceived),
             _ => match self.categorise_error_for_io(rc) {
                 Ok(IoStatus::Ok(_)) => unreachable!(),
-                Ok(IoStatus::Empty | IoStatus::EndOfStream) => {
-                    Err(Error::Io(crate::errors::IoError::EndOfStream))
-                }
+                Ok(IoStatus::Empty | IoStatus::EndOfStream) => Ok(ShutdownStatus::EndOfStream),
                 Ok(IoStatus::Retry(reason)) => Err(Error::TlsRetry(reason)),
                 Err(Error::TlsReason(TlsErrorReason::ApplicationDataOnShutdown)) => {
                     Ok(ShutdownStatus::RemainingApplicationData)
@@ -328,4 +326,6 @@
     CloseNotifyReceived,
     /// There are remaining application data. Consume them first before calling `shutdown` again.
     RemainingApplicationData,
+    /// The read half of the connection reaches the end of the stream.
+    EndOfStream,
 }