Skip to main content

UdpScionSocket

Struct UdpScionSocket 

Source
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>

Source

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.

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

pub fn local_addr(&self) -> SocketAddr

Returns the local socket address.

Trait Implementations§

Source§

impl<P: PathManager> Debug for UdpScionSocket<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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,

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,

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

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>
where P: Sync + Send,

§

impl<P> Sync for UdpScionSocket<P>
where P: Sync + Send,

§

impl<P> Unpin for UdpScionSocket<P>

§

impl<P> UnsafeUnpin for UdpScionSocket<P>

§

impl<P = MultiPathManager> !UnwindSafe for UdpScionSocket<P>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more