Skip to main content

transfer_session

Function transfer_session 

pub async fn transfer_session<A, B>(
    a: &mut A,
    b: &mut B,
    max_buffer: usize,
    abort_stream: Option<AbortRegistration>,
) -> Result<(usize, usize), Error>
where A: AsyncRead + AsyncWrite + Unpin + ?Sized, B: AsyncRead + AsyncWrite + Unpin + ?Sized,
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. Bidirectionally forwards all data between two streams until either side closes, with an equally sized buffer in both directions.

If abort_stream is given, the transfer can be aborted from the b (stream) side only; this is useful for UDP-like streams that cannot signal termination via socket closure.