pub struct TlsStream { /* private fields */ }
Implementations§
Source§impl TlsStream
impl TlsStream
Sourcepub async fn connect(
hostname: &str,
port: u16,
peer_verify: PeerVerification,
security_tags: &[u32],
ciphers: Option<&[CipherSuite]>,
resume_sessions: bool,
) -> Result<Self, Error>
pub async fn connect( hostname: &str, port: u16, peer_verify: PeerVerification, security_tags: &[u32], ciphers: Option<&[CipherSuite]>, resume_sessions: bool, ) -> Result<Self, Error>
Connect an encrypted TCP stream to the given address
This function attempts to connect to the given hostname
and port
using the specified
security parameters.
hostname
: The hostname of the server to connect to.port
: The port number of the server to connect to.peer_verify
: The peer verification policy to apply. Determines how the connection verifies the server’s identity.security_tags
: A slice of security tag identifiers containing security elements.ciphers
: An optional slice of IANA cipher suite identifiers to use for the connection. IfNone
, the default set of ciphers is used.resume_sessions
: Enable TLS session tickets, managed by the modem.
Sourcepub async fn connect_with_cancellation(
hostname: &str,
port: u16,
peer_verify: PeerVerification,
security_tags: &[u32],
ciphers: Option<&[CipherSuite]>,
resume_sessions: bool,
token: &CancellationToken,
) -> Result<Self, Error>
pub async fn connect_with_cancellation( hostname: &str, port: u16, peer_verify: PeerVerification, security_tags: &[u32], ciphers: Option<&[CipherSuite]>, resume_sessions: bool, token: &CancellationToken, ) -> Result<Self, Error>
Connect an encrypted TCP stream to the given address
This function attempts to connect to the given hostname
and port
using the specified
security parameters.
hostname
: The hostname of the server to connect to.port
: The port number of the server to connect to.peer_verify
: The peer verification policy to apply. Determines how the connection verifies the server’s identity.security_tags
: A slice of security tag identifiers containing security elements.ciphers
: An optional slice of IANA cipher suite identifiers to use for the connection. IfNone
, the default set of ciphers is used.resume_sessions
: Enable TLS session tickets, managed by the modem.token
: ACancellationToken
that can be used to cancel the connection attempt.
Sourcepub fn as_raw_fd(&self) -> i32
pub fn as_raw_fd(&self) -> i32
Get the raw underlying file descriptor for when you need to interact with the nrf libraries directly
Sourcepub async fn split_owned(
self,
) -> Result<(OwnedTlsReadStream, OwnedTlsWriteStream), Error>
pub async fn split_owned( self, ) -> Result<(OwnedTlsReadStream, OwnedTlsWriteStream), Error>
Split the stream into an owned read and write half
Sourcepub fn split(&self) -> (TlsReadStream<'_>, TlsWriteStream<'_>)
pub fn split(&self) -> (TlsReadStream<'_>, TlsWriteStream<'_>)
Split the stream into an owned read and write half
Sourcepub async fn receive<'buf>(
&self,
buf: &'buf mut [u8],
) -> Result<&'buf mut [u8], Error>
pub async fn receive<'buf>( &self, buf: &'buf mut [u8], ) -> Result<&'buf mut [u8], Error>
Try fill the given buffer with the data that has been received. The written part of the buffer is returned.
Sourcepub async fn receive_with_cancellation<'buf>(
&self,
buf: &'buf mut [u8],
token: &CancellationToken,
) -> Result<&'buf mut [u8], Error>
pub async fn receive_with_cancellation<'buf>( &self, buf: &'buf mut [u8], token: &CancellationToken, ) -> Result<&'buf mut [u8], Error>
Try fill the given buffer with the data that has been received. The written part of the buffer is returned.
Sourcepub async fn receive_exact<'buf>(
&self,
buf: &'buf mut [u8],
) -> Result<(), (Error, &'buf mut [u8])>
pub async fn receive_exact<'buf>( &self, buf: &'buf mut [u8], ) -> Result<(), (Error, &'buf mut [u8])>
Fill the entire buffer with data that has been received. This will wait as long as necessary to fill up the buffer.
If there’s an error while receiving, then the error is returned as well as the part of the buffer that was partially filled with received data.
Sourcepub async fn receive_exact_with_cancellation<'buf>(
&self,
buf: &'buf mut [u8],
token: &CancellationToken,
) -> Result<(), (Error, &'buf mut [u8])>
pub async fn receive_exact_with_cancellation<'buf>( &self, buf: &'buf mut [u8], token: &CancellationToken, ) -> Result<(), (Error, &'buf mut [u8])>
Fill the entire buffer with data that has been received. This will wait as long as necessary to fill up the buffer.
If there’s an error while receiving, then the error is returned as well as the part of the buffer that was partially filled with received data.
Sourcepub async fn write(&self, buf: &[u8]) -> Result<(), Error>
pub async fn write(&self, buf: &[u8]) -> Result<(), Error>
Write the entire buffer to the stream
Sourcepub async fn write_with_cancellation(
&self,
buf: &[u8],
token: &CancellationToken,
) -> Result<(), Error>
pub async fn write_with_cancellation( &self, buf: &[u8], token: &CancellationToken, ) -> Result<(), Error>
Write the entire buffer to the stream
Sourcepub async fn deactivate(self) -> Result<(), Error>
pub async fn deactivate(self) -> Result<(), Error>
Deactivates the socket and the LTE link. A normal drop will do the same thing, but blocking.
Trait Implementations§
Source§impl Read for TlsStream
impl Read for TlsStream
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>
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>>
buf
. Read more