mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-16 00:00:15 +02:00
Huge overhaul of bytes
* Get rid of `ByteStr` trait * `Bytes` is not a concrete type * Add `BlockBuf` * Delete lots of cruft * Performance work
This commit is contained in:
+1
-11
@@ -1,5 +1,5 @@
|
||||
use buf::{Buf, MutBuf};
|
||||
use std::{cmp, io};
|
||||
use std::{cmp};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Take<T> {
|
||||
@@ -52,16 +52,6 @@ impl<T: Buf> Buf for Take<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Buf> io::Read for Take<T> {
|
||||
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
|
||||
if !self.has_remaining() {
|
||||
return Ok(0);
|
||||
}
|
||||
|
||||
Ok(self.read_slice(buf))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: MutBuf> MutBuf for Take<T> {
|
||||
fn remaining(&self) -> usize {
|
||||
cmp::min(self.inner.remaining(), self.limit)
|
||||
|
||||
Reference in New Issue
Block a user