SplitSocketHandle

Struct SplitSocketHandle 

Source
pub struct SplitSocketHandle { /* private fields */ }
Expand description

A handle to a split socket.

Created by calling Socket::split. This allows a socket to be split into two handles that can be used independently in different async tasks (e.g., one for reading and one for writing).

Each handle maintains its own LTE link and can be deactivated independently, though the underlying socket is only closed when the last handle is dropped.

Implementations§

Source§

impl SplitSocketHandle

Source

pub async fn deactivate(self) -> Result<(), Error>

Deactivates this socket handle and its LTE link.

This will deactivate the LTE link associated with this handle. If this is the last remaining handle to the split socket, the underlying socket will also be closed.

A normal drop will do the same thing, but blocking.

Methods from Deref<Target = Socket>§

Source

pub fn as_raw_fd(&self) -> i32

Get the nrf-modem file descriptor so the user can opt out of using this high level wrapper for things

Source

pub async fn connect(&self, address: SocketAddr) -> Result<(), Error>

Connect to the given socket address.

This calls the nrfxlib_sys::nrf_connect function and can be used for tcp streams, udp connections and dtls connections.

Source

pub async unsafe fn connect_with_cancellation( &self, address: SocketAddr, token: &CancellationToken, ) -> Result<(), Error>

Connect to the given socket address.

This calls the nrfxlib_sys::nrf_connect function and can be used for tcp streams, udp connections and dtls connections.

§Safety

If the connect is cancelled, the socket may be in a weird state and should be dropped.

Source

pub async fn bind(&self, address: SocketAddr) -> Result<(), Error>

Bind the socket to a given address.

This calls the nrfxlib_sys::nrf_bind function and can be used for UDP sockets.

Source

pub async unsafe fn bind_with_cancellation( &self, address: SocketAddr, token: &CancellationToken, ) -> Result<(), Error>

Bind the socket to a given address.

This calls the nrfxlib_sys::nrf_bind function and can be used for UDP sockets.

§Safety

If the bind is cancelled, the socket may be in a weird state and should be dropped.

Source

pub async fn write(&self, buffer: &[u8]) -> Result<usize, Error>

Write data to the socket.

This calls the nrfxlib_sys::nrf_send function and can be used for TCP streams and dTLS connections.

Source

pub async fn write_with_cancellation( &self, buffer: &[u8], token: &CancellationToken, ) -> Result<usize, Error>

Write data to the socket with cancellation support.

This calls the nrfxlib_sys::nrf_send function and can be used for TCP streams and dTLS connections.

This operation can be cancelled using the provided CancellationToken.

Source

pub async fn receive(&self, buffer: &mut [u8]) -> Result<usize, Error>

Receive data from the socket.

This calls the nrfxlib_sys::nrf_recv function and can be used for TCP streams and dTLS connections.

Source

pub async fn receive_with_cancellation( &self, buffer: &mut [u8], token: &CancellationToken, ) -> Result<usize, Error>

Receive data from the socket with cancellation support.

This calls the nrfxlib_sys::nrf_recv function and can be used for TCP streams and dTLS connections.

This operation can be cancelled using the provided CancellationToken.

Source

pub async fn receive_from( &self, buffer: &mut [u8], ) -> Result<(usize, SocketAddr), Error>

Receive data from the socket along with the sender’s address.

This calls the nrfxlib_sys::nrf_recvfrom function and can be used for UDP sockets.

Source

pub async fn receive_from_with_cancellation( &self, buffer: &mut [u8], token: &CancellationToken, ) -> Result<(usize, SocketAddr), Error>

Receive data from the socket along with the sender’s address, with cancellation support.

This calls the nrfxlib_sys::nrf_recvfrom function and can be used for UDP sockets.

This operation can be cancelled using the provided CancellationToken.

Source

pub async fn send_to( &self, buffer: &[u8], address: SocketAddr, ) -> Result<usize, Error>

Send data to a specific address through the socket.

This calls the nrfxlib_sys::nrf_sendto function and can be used for UDP sockets.

Source

pub async fn send_to_with_cancellation( &self, buffer: &[u8], address: SocketAddr, token: &CancellationToken, ) -> Result<usize, Error>

Send data to a specific address through the socket with cancellation support.

This calls the nrfxlib_sys::nrf_sendto function and can be used for UDP sockets.

This operation can be cancelled using the provided CancellationToken.

Source

pub fn set_option<'a>( &'a self, option: SocketOption<'a>, ) -> Result<(), SocketOptionError>

Set a socket option.

This calls the nrfxlib_sys::nrf_setsockopt function and provides access to various socket configuration options including timeouts, TLS settings, PDN binding, and protocol-specific options.

See SocketOption for available options.

Trait Implementations§

Source§

impl Deref for SplitSocketHandle

Source§

type Target = Socket

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Drop for SplitSocketHandle

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.