Function transfer_session_datagram
pub async fn transfer_session_datagram<A, B>(
a: &mut A,
b: &mut B,
max_buffer: usize,
abort_stream: Option<AbortRegistration>,
) -> Result<(usize, usize), Error>Expand description
Bidirectionally copies data between a HoprSession and an arbitrary
async IO stream.
Re-exported from hopr-utils; the published generic version accepts any two
AsyncRead + AsyncWrite streams. Only available with Tokio.
Datagram-boundary-preserving variant of transfer_session for UDP session bridges.
Both directions of the bridge preserve datagram boundaries: each read (one UDP datagram from the stream, or one reassembled frame from the session) is written to the other side separately and flushed before the next read, instead of coalescing several reads into one oversized write under backpressure (which the segmenter can no longer split back apart). This preserves datagram boundaries; it does not guarantee exactly one write per datagram, since a single datagram may still span several writes if the writer accepts partial writes. See hoprnet#8421.
Precondition: both sides must yield at most one datagram/frame per poll_read — the UDP
StreamReader and the session’s frame reader both do. A reader that returned two datagrams in
one read would still write them together.