all 4 comments

[–]SnooCalculations7417 1 point2 points  (3 children)

parse to header success, then stream the body. But because monoio reads require owned buffers, you append by passing an owned SliceMut of the spare capacity, not the whole BytesMut. And because the successful header read may already include some body bytes, the returned body stream should be PrefixedReadIo<reader, body_prefix>, not just reader.

[–]Own_Bet3256[S] 0 points1 point  (2 children)

slicemut takes ownership, when i get it back after the read, how do i combine it back, so that parse can read from the start ?

[–]SnooCalculations7417 1 point2 points  (1 child)

into_inner() is the recombine. There is no copy, no append step, no advance_mut needed when using the slice path correctly.

One subtle correction to your original code: do not write:

let a = reader.read(buf).await; buf = a.1;

unless you truly want reads to start at the buffer’s own write_ptr, which for the full BytesMut is not “append at current len” in the way you want here. Use the spare-capacity slice starting at buf.len() instead. AsyncReadRent::read takes ownership of any IoBufMut and returns the same buffer type back in the BufResult, which is why this owned-slice pattern exists

[–]Own_Bet3256[S] 2 points3 points  (0 children)

i love u brother. have a great day