mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-10 00:00:09 +02:00
The `bytes()` / `bytes_mut()` name implies the method returns the full set of bytes represented by `Buf`/`BufMut`. To rectify this, the methods are renamed to `chunk()` and `chunk_mut()` to reflect the partial nature of the returned byte slice. `bytes_vectored()` is renamed `chunks_vectored()`. Closes #447
23 lines
379 B
Rust
23 lines
379 B
Rust
use alloc::collections::VecDeque;
|
|
|
|
use super::Buf;
|
|
|
|
impl Buf for VecDeque<u8> {
|
|
fn remaining(&self) -> usize {
|
|
self.len()
|
|
}
|
|
|
|
fn chunk(&self) -> &[u8] {
|
|
let (s1, s2) = self.as_slices();
|
|
if s1.is_empty() {
|
|
s2
|
|
} else {
|
|
s1
|
|
}
|
|
}
|
|
|
|
fn advance(&mut self, cnt: usize) {
|
|
self.drain(..cnt);
|
|
}
|
|
}
|