MCPcopy Create free account
hub / github.com/HFQR/xitca-web / encode_tls_data

Function encode_tls_data

tls/src/rustls.rs:502–515  ·  view source on GitHub ↗

Encode TLS handshake data into the write buffer, resizing if needed.

(state: &mut unbuffered::EncodeTlsData<'_, Data>, write_buf: &mut BytesMut)

Source from the content-addressed store, hash-verified

500
501/// Encode TLS handshake data into the write buffer, resizing if needed.
502fn encode_tls_data<Data>(state: &mut unbuffered::EncodeTlsData<'_, Data>, write_buf: &mut BytesMut) -> io::Result<()> {
503 // SAFETY: EncodeTlsData::encode copies a single chunk contiguously from index 0.
504 // On Ok(n), exactly n bytes are written. On InsufficientSize or AlreadyEncoded,
505 // the size check happens before any write so the slice is untouched.
506 while let Err(e) = unsafe { SpareCapBuf::new(write_buf).with_mut_slice(|slice| state.encode(slice)) } {
507 match e {
508 unbuffered::EncodeError::InsufficientSize(unbuffered::InsufficientSizeError { required_size }) => {
509 write_buf.reserve(required_size);
510 }
511 e => return Err(io::Error::new(io::ErrorKind::InvalidData, e.to_string())),
512 }
513 }
514 Ok(())
515}
516
517/// Encrypt plaintext into the write buffer, resizing if needed.
518fn encrypt_to_buf<Data>(

Callers 4

_handshakeMethod · 0.85
read_tlsMethod · 0.85
write_tlsMethod · 0.85
tls_shutdownMethod · 0.85

Calls 3

with_mut_sliceMethod · 0.80
reserveMethod · 0.80
encodeMethod · 0.45

Tested by

no test coverage detected