pub struct UdpScionSocket<P: PathManager = MultiPathManager> { /* private fields */ }Expand description
A path aware UDP socket generic over the underlay socket and path manager.
Implementations§
Source§impl<P: PathManager> UdpScionSocket<P>
impl<P: PathManager> UdpScionSocket<P>
Sourcepub fn new(
socket: PathUnawareUdpScionSocket,
pather: Arc<P>,
connect_timeout: Duration,
send_error_receivers: Subscribers<dyn SendErrorReceiver>,
) -> Self
pub fn new( socket: PathUnawareUdpScionSocket, pather: Arc<P>, connect_timeout: Duration, send_error_receivers: Subscribers<dyn SendErrorReceiver>, ) -> Self
Creates a new path aware UDP SCION socket.
Sourcepub async fn connect(
self,
remote_addr: SocketAddr,
) -> Result<Self, ScionSocketConnectError>
pub async fn connect( self, remote_addr: SocketAddr, ) -> Result<Self, ScionSocketConnectError>
Connects the socket to a remote address.
Ensures a Path to the Destination exists, returns an error if not.
Timeouts after configured connect_timeout
Sourcepub async fn send(&self, payload: &[u8]) -> Result<(), ScionSocketSendError>
pub async fn send(&self, payload: &[u8]) -> Result<(), ScionSocketSendError>
Send a datagram to the connected remote address.
§Cancel safety
This method is cancel-safe. If the future is dropped before completion, the packet may be silently lost, but no socket state is corrupted and the socket remains usable.
Sourcepub async fn send_to(
&self,
payload: &[u8],
destination: SocketAddr,
) -> Result<(), ScionSocketSendError>
pub async fn send_to( &self, payload: &[u8], destination: SocketAddr, ) -> Result<(), ScionSocketSendError>
Send a datagram to the specified destination.
§Cancel safety
This method is cancel-safe. It has two await points: the path lookup and the actual send. If the future is dropped at either point, no socket state is corrupted and the socket remains usable. A packet dropped mid-send is silently lost, which is normal for UDP.
Sourcepub async fn send_to_via(
&self,
payload: &[u8],
destination: SocketAddr,
path: &Path<&[u8]>,
) -> Result<(), ScionSocketSendError>
pub async fn send_to_via( &self, payload: &[u8], destination: SocketAddr, path: &Path<&[u8]>, ) -> Result<(), ScionSocketSendError>
Send a datagram to the specified destination via the specified path.
§Cancel safety
This method is cancel-safe. If the future is dropped before completion, the packet may be silently lost, but no socket state is corrupted and the socket remains usable.
Sourcepub async fn recv_from_with_path<'a>(
&'a self,
buffer: &'a mut [u8],
path_buffer: &'a mut [u8],
) -> Result<(usize, SocketAddr, Path<&'a mut [u8]>), ScionSocketReceiveError>
pub async fn recv_from_with_path<'a>( &'a self, buffer: &'a mut [u8], path_buffer: &'a mut [u8], ) -> Result<(usize, SocketAddr, Path<&'a mut [u8]>), ScionSocketReceiveError>
Receive a datagram from any address, along with the sender address and path.
§Cancel safety
This method is cancel-safe. The only await point is the inner underlay receive. If the
future is dropped while waiting for a packet, no packet data is consumed and buffer
and path_buffer are left unmodified.
Path registration via the path manager runs synchronously within the same poll
invocation that delivers the received data, so it cannot be independently cancelled.
Sourcepub async fn recv_from(
&self,
buffer: &mut [u8],
) -> Result<(usize, SocketAddr), ScionSocketReceiveError>
pub async fn recv_from( &self, buffer: &mut [u8], ) -> Result<(usize, SocketAddr), ScionSocketReceiveError>
Receive a datagram from the connected remote address and write it into the provided buffer.
The path of the received packet is used to register a reverse path with the path manager,
but is not returned to the caller. Use recv_from_with_path
if the path is needed.
§Cancel safety
This method is cancel-safe. If the future is dropped while waiting for a packet, no
packet is consumed and buffer is left unmodified. The contents of buffer are only
valid after the method returns Ok.
Sourcepub async fn recv(
&self,
buffer: &mut [u8],
) -> Result<usize, ScionSocketReceiveError>
pub async fn recv( &self, buffer: &mut [u8], ) -> Result<usize, ScionSocketReceiveError>
Receive a datagram from the connected remote address.
Datagrams from other addresses are silently discarded.
§Cancel safety
This method is cancel-safe. If the future is dropped while waiting for a packet, no
packet is permanently lost — the underlying receive is cancel-safe and an undelivered
packet remains available for the next call. Note that packets from other senders are
discarded during filtering; those discarded packets are not recoverable regardless of
cancellation. The contents of buffer are only valid after the method returns Ok(n).
Sourcepub fn local_addr(&self) -> SocketAddr
pub fn local_addr(&self) -> SocketAddr
Returns the local socket address.
Trait Implementations§
Source§impl<P: PathManager> Debug for UdpScionSocket<P>
impl<P: PathManager> Debug for UdpScionSocket<P>
Source§impl<P: PathManager + Sync + Send + 'static> GenericScionUdpSocket for UdpScionSocket<P>
impl<P: PathManager + Sync + Send + 'static> GenericScionUdpSocket for UdpScionSocket<P>
Source§fn send_to<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 [u8],
destination: SocketAddr,
) -> Pin<Box<dyn Future<Output = Result<(), BoxedSocketError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn send_to<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 [u8],
destination: SocketAddr,
) -> Pin<Box<dyn Future<Output = Result<(), BoxedSocketError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Asynchronously sends a Datagram to the specified destination address.
Source§fn recv_from<'life0, 'life1, 'async_trait>(
&'life0 self,
buf: &'life1 mut [u8],
) -> Pin<Box<dyn Future<Output = Result<(usize, SocketAddr), BoxedSocketError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn recv_from<'life0, 'life1, 'async_trait>(
&'life0 self,
buf: &'life1 mut [u8],
) -> Pin<Box<dyn Future<Output = Result<(usize, SocketAddr), BoxedSocketError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Asynchronously receives a Datagram, writing it into the provided buffer, and returns the number of bytes read and the source address.
Source§fn local_addr(&self) -> SocketAddr
fn local_addr(&self) -> SocketAddr
Returns the local socket address of this socket.
Auto Trait Implementations§
impl<P> Freeze for UdpScionSocket<P>
impl<P = MultiPathManager> !RefUnwindSafe for UdpScionSocket<P>
impl<P> Send for UdpScionSocket<P>
impl<P> Sync for UdpScionSocket<P>
impl<P> Unpin for UdpScionSocket<P>
impl<P> UnsafeUnpin for UdpScionSocket<P>
impl<P = MultiPathManager> !UnwindSafe for UdpScionSocket<P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request