-
-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
I'm writing a socket writer where I won't know how many bytes are consumed until after I've viewed the data.
I have roughly the following:
struct InFlight {
pos: usize,
data: Vec<u8>,
}
fn foo() -> Result<()> {
let buf = Thingbuf<InFlight>::new(10);
// feed the buf
loop {
let next = buf.front_mut(); // this function doesn't exist but I need it
let sent_bytes = send(next.data[pos..])?;
next.pos += sent_bytes;
if next.pos == next.data.len() {
buf.pop_front();
}
}
}
The key here is if I preemptively pop_front() I might not have consumed all the bytes in InFlight yet
Metadata
Metadata
Assignees
Labels
No labels