#[inline] fn advance(&mutself, mut cnt: usize) { while cnt > 0 {
{ let front = &mutself.bufs[0]; let rem = front.remaining(); if rem > cnt {
front.advance(cnt); return;
} else {
front.advance(rem);
cnt -= rem;
}
} self.bufs.pop_front();
}
}
#[inline] fn chunks_vectored<'t>(&'t self, dst: &mut [IoSlice<'t>]) -> usize { if dst.is_empty() { return0;
} letmut vecs = 0; for buf in &self.bufs {
vecs += buf.chunks_vectored(&mut dst[vecs..]); if vecs == dst.len() { break;
}
}
vecs
}
#[inline] fn copy_to_bytes(&mutself, len: usize) -> Bytes { // Our inner buffer may have an optimized version of copy_to_bytes, and if the whole // request can be fulfilled by the front buffer, we can take advantage. matchself.bufs.front_mut() {
Some(front) if front.remaining() == len => { let b = front.copy_to_bytes(len); self.bufs.pop_front();
b
}
Some(front) if front.remaining() > len => front.copy_to_bytes(len),
_ => { let rem = self.remaining();
assert!(len <= rem, "`len` greater than remaining"); letmut bm = BytesMut::with_capacity(len); if rem == len { // .take() costs a lot more, so skip it if we don't need it
bm.put(self);
} else {
bm.put(self.take(len));
}
bm.freeze()
}
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.