Struct hyper_sync_rustls::ClientSession
source · pub struct ClientSession { /* private fields */ }
Expand description
This represents a single TLS client session.
Implementations§
source§impl ClientSession
impl ClientSession
sourcepub fn new(config: &Arc<ClientConfig>, hostname: DNSNameRef<'_>) -> ClientSession ⓘ
pub fn new(config: &Arc<ClientConfig>, hostname: DNSNameRef<'_>) -> ClientSession ⓘ
Make a new ClientSession. config
controls how
we behave in the TLS protocol, hostname
is the
hostname of who we want to talk to.
sourcepub fn early_data<'a>(&'a mut self) -> Option<WriteEarlyData<'a>>
pub fn early_data<'a>(&'a mut self) -> Option<WriteEarlyData<'a>>
Returns an io::Write
implementor you can write bytes to
to send TLS1.3 early data (a.k.a. “0-RTT data”) to the server.
This returns None in many circumstances when the capability to send early data is not available, including but not limited to:
- The server hasn’t been talked to previously.
- The server does not support resumption.
- The server does not support early data.
- The resumption data for the server has expired.
The server specifies a maximum amount of early data. You can learn this limit through the returned object, and writes through it will process only this many bytes.
The server can choose not to accept any sent early data –
in this case the data is lost but the connection continues. You
can tell this happened using is_early_data_accepted
.
sourcepub fn is_early_data_accepted(&self) -> bool
pub fn is_early_data_accepted(&self) -> bool
Returns True if the server signalled it will process early data.
If you sent early data and this returns false at the end of the handshake then the server will not process the data. This is not an error, but you may wish to resend the data.
Trait Implementations§
source§impl Debug for ClientSession
impl Debug for ClientSession
source§impl Read for ClientSession
impl Read for ClientSession
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
Obtain plaintext data received from the peer over this TLS connection.
1.36.0 · source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read
, except that it reads into a slice of buffers. Read moresource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
buf
. Read more1.0.0 · source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf
. Read more1.6.0 · source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf
. Read moresource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)cursor
. Read more1.0.0 · source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read
. Read moresource§impl Session for ClientSession
impl Session for ClientSession
source§fn write_tls(&mut self, wr: &mut dyn Write) -> Result<usize, Error>
fn write_tls(&mut self, wr: &mut dyn Write) -> Result<usize, Error>
Writes TLS messages to wr
.
source§fn read_tls(&mut self, rd: &mut dyn Read) -> Result<usize, Error>
fn read_tls(&mut self, rd: &mut dyn Read) -> Result<usize, Error>
rd
. This method does internal
buffering, so rd
can supply TLS messages in arbitrary-
sized chunks (like a socket or pipe might). Read moresource§fn writev_tls(&mut self, wr: &mut dyn WriteV) -> Result<usize, Error>
fn writev_tls(&mut self, wr: &mut dyn WriteV) -> Result<usize, Error>
write_tls
, but writes potentially many records in one
go via wr
; a rustls::WriteV
. This function has the same semantics
as write_tls
otherwise. Read moresource§fn process_new_packets(&mut self) -> Result<(), TLSError>
fn process_new_packets(&mut self) -> Result<(), TLSError>
read_tls
.
Errors from this function relate to TLS protocol errors, and
are fatal to the session. Future calls after an error will do
no new work and will return the same error. Read moresource§fn wants_read(&self) -> bool
fn wants_read(&self) -> bool
read_tls
as soon
as possible. Read moresource§fn wants_write(&self) -> bool
fn wants_write(&self) -> bool
write_tls
as soon
as possible. Read moresource§fn is_handshaking(&self) -> bool
fn is_handshaking(&self) -> bool
source§fn set_buffer_limit(&mut self, len: usize)
fn set_buffer_limit(&mut self, len: usize)
source§fn send_close_notify(&mut self)
fn send_close_notify(&mut self)
write_tls
call. This informs the peer that the
connection is being closed. Read moresource§fn get_peer_certificates(&self) -> Option<Vec<Certificate, Global>>
fn get_peer_certificates(&self) -> Option<Vec<Certificate, Global>>
source§fn get_alpn_protocol(&self) -> Option<&str>
fn get_alpn_protocol(&self) -> Option<&str>
source§fn get_protocol_version(&self) -> Option<ProtocolVersion>
fn get_protocol_version(&self) -> Option<ProtocolVersion>
source§fn export_keying_material(
&self,
output: &mut [u8],
label: &[u8],
context: Option<&[u8]>
) -> Result<(), TLSError>
fn export_keying_material(
&self,
output: &mut [u8],
label: &[u8],
context: Option<&[u8]>
) -> Result<(), TLSError>
source§fn get_negotiated_ciphersuite(&self) -> Option<&'static SupportedCipherSuite>
fn get_negotiated_ciphersuite(&self) -> Option<&'static SupportedCipherSuite>
source§impl Write for ClientSession
impl Write for ClientSession
source§fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
Send the plaintext buf
to the peer, encrypting
and authenticating it. Once this function succeeds
you should call write_tls
which will output the
corresponding TLS records.
This function buffers plaintext sent before the TLS handshake completes, and sends it as soon as it can. This buffer is of unlimited size so writing much data before it can be sent will cause excess memory usage.
source§fn flush(&mut self) -> Result<(), Error>
fn flush(&mut self) -> Result<(), Error>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)Auto Trait Implementations§
impl !RefUnwindSafe for ClientSession
impl Send for ClientSession
impl Sync for ClientSession
impl Unpin for ClientSession
impl !UnwindSafe for ClientSession
Blanket Implementations§
§impl<R> ReadBytesExt for Rwhere
R: Read + ?Sized,
impl<R> ReadBytesExt for Rwhere
R: Read + ?Sized,
§fn read_u8(&mut self) -> Result<u8, Error>
fn read_u8(&mut self) -> Result<u8, Error>
§fn read_i8(&mut self) -> Result<i8, Error>
fn read_i8(&mut self) -> Result<i8, Error>
§fn read_u16<T>(&mut self) -> Result<u16, Error>where
T: ByteOrder,
fn read_u16<T>(&mut self) -> Result<u16, Error>where
T: ByteOrder,
§fn read_i16<T>(&mut self) -> Result<i16, Error>where
T: ByteOrder,
fn read_i16<T>(&mut self) -> Result<i16, Error>where
T: ByteOrder,
§fn read_u24<T>(&mut self) -> Result<u32, Error>where
T: ByteOrder,
fn read_u24<T>(&mut self) -> Result<u32, Error>where
T: ByteOrder,
§fn read_i24<T>(&mut self) -> Result<i32, Error>where
T: ByteOrder,
fn read_i24<T>(&mut self) -> Result<i32, Error>where
T: ByteOrder,
§fn read_u32<T>(&mut self) -> Result<u32, Error>where
T: ByteOrder,
fn read_u32<T>(&mut self) -> Result<u32, Error>where
T: ByteOrder,
§fn read_i32<T>(&mut self) -> Result<i32, Error>where
T: ByteOrder,
fn read_i32<T>(&mut self) -> Result<i32, Error>where
T: ByteOrder,
§fn read_u48<T>(&mut self) -> Result<u64, Error>where
T: ByteOrder,
fn read_u48<T>(&mut self) -> Result<u64, Error>where
T: ByteOrder,
§fn read_i48<T>(&mut self) -> Result<i64, Error>where
T: ByteOrder,
fn read_i48<T>(&mut self) -> Result<i64, Error>where
T: ByteOrder,
§fn read_u64<T>(&mut self) -> Result<u64, Error>where
T: ByteOrder,
fn read_u64<T>(&mut self) -> Result<u64, Error>where
T: ByteOrder,
§fn read_i64<T>(&mut self) -> Result<i64, Error>where
T: ByteOrder,
fn read_i64<T>(&mut self) -> Result<i64, Error>where
T: ByteOrder,
§fn read_u128<T>(&mut self) -> Result<u128, Error>where
T: ByteOrder,
fn read_u128<T>(&mut self) -> Result<u128, Error>where
T: ByteOrder,
§fn read_i128<T>(&mut self) -> Result<i128, Error>where
T: ByteOrder,
fn read_i128<T>(&mut self) -> Result<i128, Error>where
T: ByteOrder,
§fn read_uint<T>(&mut self, nbytes: usize) -> Result<u64, Error>where
T: ByteOrder,
fn read_uint<T>(&mut self, nbytes: usize) -> Result<u64, Error>where
T: ByteOrder,
§fn read_int<T>(&mut self, nbytes: usize) -> Result<i64, Error>where
T: ByteOrder,
fn read_int<T>(&mut self, nbytes: usize) -> Result<i64, Error>where
T: ByteOrder,
§fn read_uint128<T>(&mut self, nbytes: usize) -> Result<u128, Error>where
T: ByteOrder,
fn read_uint128<T>(&mut self, nbytes: usize) -> Result<u128, Error>where
T: ByteOrder,
§fn read_int128<T>(&mut self, nbytes: usize) -> Result<i128, Error>where
T: ByteOrder,
fn read_int128<T>(&mut self, nbytes: usize) -> Result<i128, Error>where
T: ByteOrder,
§fn read_f32<T>(&mut self) -> Result<f32, Error>where
T: ByteOrder,
fn read_f32<T>(&mut self) -> Result<f32, Error>where
T: ByteOrder,
§fn read_f64<T>(&mut self) -> Result<f64, Error>where
T: ByteOrder,
fn read_f64<T>(&mut self) -> Result<f64, Error>where
T: ByteOrder,
§fn read_u16_into<T>(&mut self, dst: &mut [u16]) -> Result<(), Error>where
T: ByteOrder,
fn read_u16_into<T>(&mut self, dst: &mut [u16]) -> Result<(), Error>where
T: ByteOrder,
§fn read_u32_into<T>(&mut self, dst: &mut [u32]) -> Result<(), Error>where
T: ByteOrder,
fn read_u32_into<T>(&mut self, dst: &mut [u32]) -> Result<(), Error>where
T: ByteOrder,
§fn read_u64_into<T>(&mut self, dst: &mut [u64]) -> Result<(), Error>where
T: ByteOrder,
fn read_u64_into<T>(&mut self, dst: &mut [u64]) -> Result<(), Error>where
T: ByteOrder,
§fn read_u128_into<T>(&mut self, dst: &mut [u128]) -> Result<(), Error>where
T: ByteOrder,
fn read_u128_into<T>(&mut self, dst: &mut [u128]) -> Result<(), Error>where
T: ByteOrder,
§fn read_i8_into(&mut self, dst: &mut [i8]) -> Result<(), Error>
fn read_i8_into(&mut self, dst: &mut [i8]) -> Result<(), Error>
§fn read_i16_into<T>(&mut self, dst: &mut [i16]) -> Result<(), Error>where
T: ByteOrder,
fn read_i16_into<T>(&mut self, dst: &mut [i16]) -> Result<(), Error>where
T: ByteOrder,
§fn read_i32_into<T>(&mut self, dst: &mut [i32]) -> Result<(), Error>where
T: ByteOrder,
fn read_i32_into<T>(&mut self, dst: &mut [i32]) -> Result<(), Error>where
T: ByteOrder,
§fn read_i64_into<T>(&mut self, dst: &mut [i64]) -> Result<(), Error>where
T: ByteOrder,
fn read_i64_into<T>(&mut self, dst: &mut [i64]) -> Result<(), Error>where
T: ByteOrder,
§fn read_i128_into<T>(&mut self, dst: &mut [i128]) -> Result<(), Error>where
T: ByteOrder,
fn read_i128_into<T>(&mut self, dst: &mut [i128]) -> Result<(), Error>where
T: ByteOrder,
§fn read_f32_into<T>(&mut self, dst: &mut [f32]) -> Result<(), Error>where
T: ByteOrder,
fn read_f32_into<T>(&mut self, dst: &mut [f32]) -> Result<(), Error>where
T: ByteOrder,
§fn read_f32_into_unchecked<T>(&mut self, dst: &mut [f32]) -> Result<(), Error>where
T: ByteOrder,
fn read_f32_into_unchecked<T>(&mut self, dst: &mut [f32]) -> Result<(), Error>where
T: ByteOrder,
read_f32_into
instead