diff options
author | Lucio Franco <luciofranco14@gmail.com> | 2020-10-12 12:41:40 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-12 12:41:40 -0400 |
commit | f8c91f2ead24ed6e268a820405c329032dd30da6 (patch) | |
tree | 49df96ec1434bd5f253f1cec9422cadb1ca1be6a /tokio/src/io | |
parent | b5750825431afe6fe227a6fcf30a593b51ceff1b (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/src/io')
-rw-r--r-- | tokio/src/io/async_read.rs | 4 | ||||
-rw-r--r-- | tokio/src/io/blocking.rs | 2 | ||||
-rw-r--r-- | tokio/src/io/poll_evented.rs | 2 | ||||
-rw-r--r-- | tokio/src/io/read_buf.rs | 6 | ||||
-rw-r--r-- | tokio/src/io/util/buf_reader.rs | 2 | ||||
-rw-r--r-- | tokio/src/io/util/mem.rs | 2 | ||||
-rw-r--r-- | tokio/src/io/util/repeat.rs | 2 | ||||
-rw-r--r-- | tokio/src/io/util/take.rs | 2 |
8 files changed, 11 insertions, 11 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(())) } |