aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/ssl/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'openssl/src/ssl/error.rs')
-rw-r--r--openssl/src/ssl/error.rs44
1 files changed, 43 insertions, 1 deletions
diff --git a/openssl/src/ssl/error.rs b/openssl/src/ssl/error.rs
index 9ff6cae9..0126b277 100644
--- a/openssl/src/ssl/error.rs
+++ b/openssl/src/ssl/error.rs
@@ -17,7 +17,20 @@ pub enum SslError {
/// The SSL session has been closed by the other end
SslSessionClosed,
/// An error in the OpenSSL library
- OpenSslErrors(Vec<OpensslError>)
+ OpenSslErrors(Vec<OpensslError>),
+}
+
+/// An error on a nonblocking stream.
+#[derive(Debug)]
+pub enum NonblockingSslError {
+ /// A standard SSL error occurred.
+ SslError(SslError),
+ /// The OpenSSL library wants data from the remote socket;
+ /// the caller should wait for read readiness.
+ WantRead,
+ /// The OpenSSL library wants to send data to the remote socket;
+ /// the caller should wait for write readiness.
+ WantWrite,
}
impl fmt::Display for SslError {
@@ -59,6 +72,35 @@ impl error::Error for SslError {
}
}
+impl fmt::Display for NonblockingSslError {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fmt.write_str(error::Error::description(self))
+ }
+}
+
+impl error::Error for NonblockingSslError {
+ fn description(&self) -> &str {
+ match *self {
+ NonblockingSslError::SslError(ref e) => e.description(),
+ NonblockingSslError::WantRead => "The OpenSSL library wants data from the remote socket",
+ NonblockingSslError::WantWrite => "The OpenSSL library want to send data to the remote socket",
+ }
+ }
+
+ fn cause(&self) -> Option<&error::Error> {
+ match *self {
+ NonblockingSslError::SslError(ref e) => e.cause(),
+ _ => None
+ }
+ }
+}
+
+impl From<SslError> for NonblockingSslError {
+ fn from(e: SslError) -> NonblockingSslError {
+ NonblockingSslError::SslError(e)
+ }
+}
+
/// An error from the OpenSSL library
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum OpensslError {