pub struct EspAsyncTls<S>(/* private fields */)
where
S: PollableSocket;Implementations§
Source§impl<S> EspAsyncTls<S>where
S: PollableSocket,
impl<S> EspAsyncTls<S>where
S: PollableSocket,
Sourcepub fn adopt(socket: S) -> Result<Self, EspError>
pub fn adopt(socket: S) -> Result<Self, EspError>
Create a new AsyncEspTls instance adopting the supplied socket.
The socket should be in a connected state.
§Errors
ESP_ERR_NO_MEMif not enough memory to create the TLS connection
Sourcepub async fn negotiate(
&mut self,
hostname: &str,
cfg: &Config<'_>,
) -> Result<CompletedHandshake, EspError>
pub async fn negotiate( &mut self, hostname: &str, cfg: &Config<'_>, ) -> Result<CompletedHandshake, EspError>
Establish a TLS/SSL connection using the adopted socket.
§Errors
ESP_ERR_INVALID_SIZEifcfg.alpn_protosexceeds 9 elements or avg 10 bytes/ALPNESP_FAILif connection could not be established
Sourcepub async fn negotiate_server(
&mut self,
cfg: &ServerConfig<'_>,
) -> Result<(), EspError>
pub async fn negotiate_server( &mut self, cfg: &ServerConfig<'_>, ) -> Result<(), EspError>
Establish a TLS/SSL connection using the adopted socket, acting as the server.
Requires ESP-IDF >= 5.5.0 with mbedTLS.
Note that the handshake is not bounded in time (cfg.tls_handshake_timeout_ms
is only honored by the blocking EspTls::negotiate_server), so a
misbehaving peer can keep the negotiation going indefinitely.
Callers which cannot afford that should race this future against a timer.
§Errors
ESP_FAILif the connection could not be established
Sourcepub async fn read(&self, buf: &mut [u8]) -> Result<usize, EspError>
pub async fn read(&self, buf: &mut [u8]) -> Result<usize, EspError>
Read in the supplied buffer. Returns the number of bytes read.
pub fn poll_read( &self, ctx: &mut Context<'_>, buf: &mut [u8], ) -> Poll<Result<usize, EspError>>
Sourcepub async fn write(&self, buf: &[u8]) -> Result<usize, EspError>
pub async fn write(&self, buf: &[u8]) -> Result<usize, EspError>
Write the supplied buffer. Returns the number of bytes written.
pub fn poll_write( &self, ctx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, EspError>>
pub async fn write_all(&self, buf: &[u8]) -> Result<(), EspError>
pub fn context_handle(&self) -> *mut esp_tls
Trait Implementations§
Source§impl<S> AsyncRead for EspAsyncTls<S>where
S: PollableSocket,
Available on crate feature std and non-esp_idf_version_major=4 and (non-esp_idf_version_major=5 or non-esp_idf_version_minor=0) only.
impl<S> AsyncRead for EspAsyncTls<S>where
S: PollableSocket,
Available on crate feature
std and non-esp_idf_version_major=4 and (non-esp_idf_version_major=5 or non-esp_idf_version_minor=0) only.Source§impl<S> AsyncRead for &EspAsyncTls<S>where
S: PollableSocket,
Available on crate feature std and non-esp_idf_version_major=4 and (non-esp_idf_version_major=5 or non-esp_idf_version_minor=0) only.
impl<S> AsyncRead for &EspAsyncTls<S>where
S: PollableSocket,
Available on crate feature
std and non-esp_idf_version_major=4 and (non-esp_idf_version_major=5 or non-esp_idf_version_minor=0) only.Source§impl<S> AsyncWrite for EspAsyncTls<S>where
S: PollableSocket,
Available on crate feature std and non-esp_idf_version_major=4 and (non-esp_idf_version_major=5 or non-esp_idf_version_minor=0) only.
impl<S> AsyncWrite for EspAsyncTls<S>where
S: PollableSocket,
Available on crate feature
std and non-esp_idf_version_major=4 and (non-esp_idf_version_major=5 or non-esp_idf_version_minor=0) only.Source§fn poll_write(
self: Pin<&mut Self>,
ctx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, ctx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize>>
Attempt to write bytes from
buf into the object. Read moreSource§fn poll_flush(self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Result<()>>
Attempt to flush the object, ensuring that any buffered data reach
their destination. Read more
Source§fn poll_close(self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_close(self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Result<()>>
Attempt to close the object. Read more
Source§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>
Attempt to write bytes from
bufs into the object using vectored
IO operations. Read moreSource§impl<S> AsyncWrite for &EspAsyncTls<S>where
S: PollableSocket,
Available on crate feature std and non-esp_idf_version_major=4 and (non-esp_idf_version_major=5 or non-esp_idf_version_minor=0) only.
impl<S> AsyncWrite for &EspAsyncTls<S>where
S: PollableSocket,
Available on crate feature
std and non-esp_idf_version_major=4 and (non-esp_idf_version_major=5 or non-esp_idf_version_minor=0) only.Source§fn poll_write(
self: Pin<&mut Self>,
ctx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, ctx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize>>
Attempt to write bytes from
buf into the object. Read moreSource§fn poll_flush(self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Result<()>>
Attempt to flush the object, ensuring that any buffered data reach
their destination. Read more
Source§fn poll_close(self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_close(self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Result<()>>
Attempt to close the object. Read more
Source§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>
Attempt to write bytes from
bufs into the object using vectored
IO operations. Read moreSource§impl<S> ErrorType for EspAsyncTls<S>where
S: PollableSocket,
Available on non-esp_idf_version_major=4 and (non-esp_idf_version_major=5 or non-esp_idf_version_minor=0) only.
impl<S> ErrorType for EspAsyncTls<S>where
S: PollableSocket,
Available on non-
esp_idf_version_major=4 and (non-esp_idf_version_major=5 or non-esp_idf_version_minor=0) only.Source§type Error = EspIOError
type Error = EspIOError
Error type of all the IO operations on this type.
Source§impl<S> Read for EspAsyncTls<S>where
S: PollableSocket,
Available on non-esp_idf_version_major=4 and (non-esp_idf_version_major=5 or non-esp_idf_version_minor=0) only.
impl<S> Read for EspAsyncTls<S>where
S: PollableSocket,
Available on non-
esp_idf_version_major=4 and (non-esp_idf_version_major=5 or non-esp_idf_version_minor=0) only.Source§async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§async fn read_exact(
&mut self,
buf: &mut [u8],
) -> Result<(), ReadExactError<Self::Error>>
async fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>
Read the exact number of bytes required to fill
buf. Read moreSource§impl<S> Write for EspAsyncTls<S>where
S: PollableSocket,
Available on non-esp_idf_version_major=4 and (non-esp_idf_version_major=5 or non-esp_idf_version_minor=0) only.
impl<S> Write for EspAsyncTls<S>where
S: PollableSocket,
Available on non-
esp_idf_version_major=4 and (non-esp_idf_version_major=5 or non-esp_idf_version_minor=0) only.Source§async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
Write a buffer into this writer, returning how many bytes were written. Read more