diff options
| author | Brian Vincent <[email protected]> | 2017-11-06 23:18:31 -0600 |
|---|---|---|
| committer | Brian Vincent <[email protected]> | 2017-11-06 23:18:31 -0600 |
| commit | 4a6fe97f9cf907ddc773687c815eee681a6f6513 (patch) | |
| tree | eaba3019acc1ea4d84dd71b42ac38380b9202063 /openssl/src/ssl/error.rs | |
| parent | Add an example of making a CA and certs and verifying. (diff) | |
| parent | Add an example of making a CA and certs and verifying. (diff) | |
| download | rust-openssl-4a6fe97f9cf907ddc773687c815eee681a6f6513.tar.xz rust-openssl-4a6fe97f9cf907ddc773687c815eee681a6f6513.zip | |
Merge branch 'my-temp-work'
Diffstat (limited to 'openssl/src/ssl/error.rs')
| -rw-r--r-- | openssl/src/ssl/error.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/openssl/src/ssl/error.rs b/openssl/src/ssl/error.rs index db78e2c8..2244fd7f 100644 --- a/openssl/src/ssl/error.rs +++ b/openssl/src/ssl/error.rs @@ -66,6 +66,33 @@ impl From<ErrorStack> for Error { } } +/// An error indicating that the operation can be immediately retried. +/// +/// OpenSSL's [`SSL_read`] and [`SSL_write`] functions can return `SSL_ERROR_WANT_READ` even when +/// the underlying socket is performing blocking IO in certain cases. When this happens, the +/// the operation can be immediately retried. +/// +/// To signal this event, the `io::Error` inside of [`Error::WantRead`] will be constructed around +/// a `RetryError`. +/// +/// [`SSL_read`]: https://www.openssl.org/docs/manmaster/man3/SSL_read.html +/// [`SSL_write`]: https://www.openssl.org/docs/manmaster/man3/SSL_write.html +/// [`Error::WantRead`]: enum.Error.html#variant.WantRead +#[derive(Debug)] +pub struct RetryError; + +impl fmt::Display for RetryError { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.write_str(error::Error::description(self)) + } +} + +impl error::Error for RetryError { + fn description(&self) -> &str { + "operation must be retried" + } +} + /// An error or intermediate state after a TLS handshake attempt. #[derive(Debug)] pub enum HandshakeError<S> { |