summaryrefslogtreecommitdiffstats
path: root/tokio
diff options
context:
space:
mode:
authorLucio Franco <luciofranco14@gmail.com>2020-10-12 12:41:40 -0400
committerGitHub <noreply@github.com>2020-10-12 12:41:40 -0400
commitf8c91f2ead24ed6e268a820405c329032dd30da6 (patch)
tree49df96ec1434bd5f253f1cec9422cadb1ca1be6a /tokio
parentb5750825431afe6fe227a6fcf30a593b51ceff1b (diff)
io: Rename `ReadBuf` methods (#2945)
This changes `ReadBuf::add_filled` to `ReadBuf::advance` and `ReadBuf::append` to `ReadBuf::put_slice`. This is just a mechanical change. Closes #2769
Diffstat (limited to 'tokio')
-rw-r--r--tokio/src/io/async_read.rs4
-rw-r--r--tokio/src/io/blocking.rs2
-rw-r--r--tokio/src/io/poll_evented.rs2
-rw-r--r--tokio/src/io/read_buf.rs6
-rw-r--r--tokio/src/io/util/buf_reader.rs2
-rw-r--r--tokio/src/io/util/mem.rs2
-rw-r--r--tokio/src/io/util/repeat.rs2
-rw-r--r--tokio/src/io/util/take.rs2
-rw-r--r--tokio/src/net/tcp/stream.rs2
-rw-r--r--tokio/src/net/unix/stream.rs2
-rw-r--r--tokio/tests/io_copy.rs2
-rw-r--r--tokio/tests/io_read.rs2
-rw-r--r--tokio/tests/io_split.rs2
13 files changed, 16 insertions, 16 deletions
diff --git a/tokio/src/io/async_read.rs b/tokio/src/io/async_read.rs
index ba2303d1..b9b0f437 100644
--- a/tokio/src/io/async_read.rs
+++ b/tokio/src/io/async_read.rs
@@ -97,7 +97,7 @@ impl AsyncRead for &[u8] {
) -> Poll<io::Result<()>> {
let amt = std::cmp::min(self.len(), buf.remaining());
let (a, b) = self.split_at(amt);
- buf.append(a);
+ buf.put_slice(a);
*self = b;
Poll::Ready(Ok(()))
}
@@ -121,7 +121,7 @@ impl<T: AsRef<[u8]> + Unpin> AsyncRead for io::Cursor<T> {
let amt = std::cmp::min(slice.len() - start, buf.remaining());
// Add won't overflow because of pos check above.
let end = start + amt;
- buf.append(&slice[start..end]);
+ buf.put_slice(&slice[start..end]);
self.set_position(end as u64);
Poll::Ready(Ok(()))
diff --git a/tokio/src/io/blocking.rs b/tokio/src/io/blocking.rs
index d2265a00..430801ee 100644
--- a/tokio/src/io/blocking.rs
+++ b/tokio/src/io/blocking.rs
@@ -205,7 +205,7 @@ impl Buf {
pub(crate) fn copy_to(&mut self, dst: &mut ReadBuf<'_>) -> usize {
let n = cmp::min(self.len(), dst.remaining());
- dst.append(&self.bytes()[..n]);
+ dst.put_slice(&self.bytes()[..n]);
self.pos += n;
if self.pos == self.buf.len() {
diff --git a/tokio/src/io/poll_evented.rs b/tokio/src/io/poll_evented.rs
index 4457195f..f253f0bb 100644
--- a/tokio/src/io/poll_evented.rs
+++ b/tokio/src/io/poll_evented.rs
@@ -249,7 +249,7 @@ impl<E: Source + Read + Unpin> AsyncRead for PollEvented<E> {
}
return Poll::Ready(r.map(|n| {
- buf.add_filled(n);
+ buf.advance(n);
}));
}
}
diff --git a/tokio/src/io/read_buf.rs b/tokio/src/io/read_buf.rs
index 8b430ee1..b64d95ce 100644
--- a/tokio/src/io/read_buf.rs
+++ b/tokio/src/io/read_buf.rs
@@ -171,7 +171,7 @@ impl<'a> ReadBuf<'a> {
self.filled = 0;
}
- /// Increases the size of the filled region of the buffer.
+ /// Advances the size of the filled region of the buffer.
///
/// The number of initialized bytes is not changed.
///
@@ -179,7 +179,7 @@ impl<'a> ReadBuf<'a> {
///
/// Panics if the filled region of the buffer would become larger than the initialized region.
#[inline]
- pub fn add_filled(&mut self, n: usize) {
+ pub fn advance(&mut self, n: usize) {
let new = self.filled.checked_add(n).expect("filled overflow");
self.set_filled(new);
}
@@ -225,7 +225,7 @@ impl<'a> ReadBuf<'a> {
///
/// Panics if `self.remaining()` is less than `buf.len()`.
#[inline]
- pub fn append(&mut self, buf: &[u8]) {
+ pub fn put_slice(&mut self, buf: &[u8]) {
assert!(
self.remaining() >= buf.len(),
"buf.len() must fit in remaining()"
diff --git a/tokio/src/io/util/buf_reader.rs b/tokio/src/io/util/buf_reader.rs
index 9264ca59..271f61bf 100644
--- a/tokio/src/io/util/buf_reader.rs
+++ b/tokio/src/io/util/buf_reader.rs
@@ -111,7 +111,7 @@ impl<R: AsyncRead> AsyncRead for BufReader<R> {
}
let rem = ready!(self.as_mut().poll_fill_buf(cx))?;
let amt = std::cmp::min(rem.len(), buf.remaining());
- buf.append(&rem[..amt]);
+ buf.put_slice(&rem[..amt]);
self.consume(amt);
Poll::Ready(Ok(()))
}
diff --git a/tokio/src/io/util/mem.rs b/tokio/src/io/util/mem.rs
index 0dd6ad77..e91a9328 100644
--- a/tokio/src/io/util/mem.rs
+++ b/tokio/src/io/util/mem.rs
@@ -167,7 +167,7 @@ impl AsyncRead for Pipe {
) -> Poll<std::io::Result<()>> {
if self.buffer.has_remaining() {
let max = self.buffer.remaining().min(buf.remaining());
- buf.append(&self.buffer[..max]);
+ buf.put_slice(&self.buffer[..max]);
self.buffer.advance(max);
if max > 0 {
// The passed `buf` might have been empty, don't wake up if
diff --git a/tokio/src/io/util/repeat.rs b/tokio/src/io/util/repeat.rs
index b942691d..1142765d 100644
--- a/tokio/src/io/util/repeat.rs
+++ b/tokio/src/io/util/repeat.rs
@@ -55,7 +55,7 @@ impl AsyncRead for Repeat {
) -> Poll<io::Result<()>> {
// TODO: could be faster, but should we unsafe it?
while buf.remaining() != 0 {
- buf.append(&[self.byte]);
+ buf.put_slice(&[self.byte]);
}
Poll::Ready(Ok(()))
}
diff --git a/tokio/src/io/util/take.rs b/tokio/src/io/util/take.rs
index 4e424f6c..b5e90c93 100644
--- a/tokio/src/io/util/take.rs
+++ b/tokio/src/io/util/take.rs
@@ -93,7 +93,7 @@ impl<R: AsyncRead> AsyncRead for Take<R> {
unsafe {
buf.assume_init(n);
}
- buf.add_filled(n);
+ buf.advance(n);
*me.limit_ -= n as u64;
Poll::Ready(Ok(()))
}
diff --git a/tokio/src/net/tcp/stream.rs b/tokio/src/net/tcp/stream.rs
index ee24ee32..0a58e481 100644
--- a/tokio/src/net/tcp/stream.rs
+++ b/tokio/src/net/tcp/stream.rs
@@ -503,7 +503,7 @@ impl TcpStream {
unsafe {
buf.assume_init(n);
}
- buf.add_filled(n);
+ buf.advance(n);
return Poll::Ready(Ok(()));
}
Err(e) => return Poll::Ready(Err(e)),
diff --git a/tokio/src/net/unix/stream.rs b/tokio/src/net/unix/stream.rs
index d0f98f43..c539f224 100644
--- a/tokio/src/net/unix/stream.rs
+++ b/tokio/src/net/unix/stream.rs
@@ -215,7 +215,7 @@ impl UnixStream {
unsafe {
buf.assume_init(n);
}
- buf.add_filled(n);
+ buf.advance(n);
return Poll::Ready(Ok(()));
}
Err(e) => return Poll::Ready(Err(e)),
diff --git a/tokio/tests/io_copy.rs b/tokio/tests/io_copy.rs
index aed6c789..9ed7995c 100644
--- a/tokio/tests/io_copy.rs
+++ b/tokio/tests/io_copy.rs
@@ -18,7 +18,7 @@ async fn copy() {
buf: &mut ReadBuf<'_>,
) -> Poll<io::Result<()>> {
if self.0 {
- buf.append(b"hello world");
+ buf.put_slice(b"hello world");
self.0 = false;
Poll::Ready(Ok(()))
} else {
diff --git a/tokio/tests/io_read.rs b/tokio/tests/io_read.rs
index 0a717cf5..29d7d6d7 100644
--- a/tokio/tests/io_read.rs
+++ b/tokio/tests/io_read.rs
@@ -24,7 +24,7 @@ async fn read() {
assert_eq!(0, self.poll_cnt);
self.poll_cnt += 1;
- buf.append(b"hello world");
+ buf.put_slice(b"hello world");
Poll::Ready(Ok(()))
}
}
diff --git a/tokio/tests/io_split.rs b/tokio/tests/io_split.rs
index 7b401424..db168e9f 100644
--- a/tokio/tests/io_split.rs
+++ b/tokio/tests/io_split.rs
@@ -15,7 +15,7 @@ impl AsyncRead for RW {
_cx: &mut Context<'_>,
buf: &mut ReadBuf<'_>,
) -> Poll<io::Result<()>> {
- buf.append(&[b'z']);
+ buf.put_slice(&[b'z']);
Poll::Ready(Ok(()))
}
}