Try to read plaintext data from TLS connection buffer Returns Ok(Some(n)) if n bytes were read, Ok(None) if would block, or Err on real errors.
(conn: &mut TlsConnection, buf: &mut [u8])
| 1414 | /// Returns Ok(Some(n)) if n bytes were read, Ok(None) if would block, |
| 1415 | /// or Err on real errors. |
| 1416 | fn try_read_plaintext(conn: &mut TlsConnection, buf: &mut [u8]) -> SslResult<Option<usize>> { |
| 1417 | let mut reader = conn.reader(); |
| 1418 | match reader.read(buf) { |
| 1419 | Ok(0) => { |
| 1420 | // EOF from TLS connection |
| 1421 | Ok(Some(0)) |
| 1422 | } |
| 1423 | Ok(n) => { |
| 1424 | // Successfully read n bytes |
| 1425 | Ok(Some(n)) |
| 1426 | } |
| 1427 | Err(e) if e.kind() != std::io::ErrorKind::WouldBlock => { |
| 1428 | // Real error |
| 1429 | Err(SslError::Io(e)) |
| 1430 | } |
| 1431 | Err(_) => { |
| 1432 | // WouldBlock - no plaintext available |
| 1433 | Ok(None) |
| 1434 | } |
| 1435 | } |
| 1436 | } |
| 1437 | |
| 1438 | /// Equivalent to OpenSSL's SSL_do_handshake() |
| 1439 | /// |