MCPcopy Index your code
hub / github.com/RustPython/RustPython / try_read_plaintext

Function try_read_plaintext

crates/stdlib/src/ssl/compat.rs:1416–1436  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

1414/// Returns Ok(Some(n)) if n bytes were read, Ok(None) if would block,
1415/// or Err on real errors.
1416fn 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///

Callers 1

ssl_readFunction · 0.85

Calls 5

SomeClass · 0.50
ErrClass · 0.50
readerMethod · 0.45
readMethod · 0.45
kindMethod · 0.45

Tested by

no test coverage detected