CustomEndpoint

Trait CustomEndpoint 

Source
pub trait CustomEndpoint:
    Debug
    + Send
    + Sync
    + 'static {
    // Required methods
    fn watch_local_addrs(&self) -> Direct<Vec<CustomAddr>>;
    fn create_sender(&self) -> Arc<dyn CustomSender>;
    fn poll_recv(
        &mut self,
        cx: &mut Context<'_>,
        bufs: &mut [IoSliceMut<'_>],
        metas: &mut [RecvMeta],
        recv_infos: &mut [RecvInfo],
    ) -> Poll<Result<usize>>;

    // Provided method
    fn max_transmit_segments(&self) -> NonZeroUsize { ... }
}
Available on crate feature unstable-custom-transports only.
Expand description

Custom endpoint created by a CustomTransport.

An endpoint has a local address (or multiple local addresses), can receive packets, and can create senders to send packets.

Required Methods§

Source

fn watch_local_addrs(&self) -> Direct<Vec<CustomAddr>>

A watcher for local addresses for this custom endpoint.

Source

fn create_sender(&self) -> Arc<dyn CustomSender>

Create a custom sender for this custom endpoint.

Source

fn poll_recv( &mut self, cx: &mut Context<'_>, bufs: &mut [IoSliceMut<'_>], metas: &mut [RecvMeta], recv_infos: &mut [RecvInfo], ) -> Poll<Result<usize>>

poll receiving a packet on this custom endpoint.

This will be called with bufs, metas and recv_infos of the same length. It is acceptable to panic if this is not the case.

The maximum length of the slices is [noq_udp::BATCH_SIZE]. It is acceptable to panic if this is exceeded.

On success, all three slices must be filled up to the returned length, and the returned length must be less than or equal to the length of the slices.

It does not make much sense to return addresses unrelated to this transport.

For each filled slot, write a RecvInfo::new carrying the remote custom address and, if the transport can identify it, the local custom address that received the packet. The latter surfaces via crate::endpoint::Incoming::local_addr.

Provided Methods§

Source

fn max_transmit_segments(&self) -> NonZeroUsize

Maximum number of segments to transmit (GSO).

This controls how many datagrams Noq will batch into a single transmit. The default is 1 (no batching). Custom transports that support batching can override this to allow more efficient transmission.

Trait Implementations§

Source§

impl Display for Box<dyn CustomEndpoint>

Source§

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

Formats the value using the given formatter. Read more

Implementors§

Source§

impl CustomEndpoint for TestTransport

Available on crate features test-utils only.