mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
io: fix documents (#1231)
This commit is contained in:
parent
70eca184f0
commit
ceed29586b
@ -53,13 +53,13 @@ pub trait AsyncRead {
|
|||||||
///
|
///
|
||||||
/// This function isn't actually `unsafe` to call but `unsafe` to implement.
|
/// This function isn't actually `unsafe` to call but `unsafe` to implement.
|
||||||
/// The implementer must ensure that either the whole `buf` has been zeroed
|
/// The implementer must ensure that either the whole `buf` has been zeroed
|
||||||
/// or `read_buf()` overwrites the buffer without reading it and returns
|
/// or `poll_read_buf()` overwrites the buffer without reading it and returns
|
||||||
/// correct value.
|
/// correct value.
|
||||||
///
|
///
|
||||||
/// This function is called from [`read_buf`].
|
/// This function is called from [`poll_read_buf`].
|
||||||
///
|
///
|
||||||
/// [`io::Read`]: https://doc.rust-lang.org/std/io/trait.Read.html
|
/// [`io::Read`]: https://doc.rust-lang.org/std/io/trait.Read.html
|
||||||
/// [`read_buf`]: #method.read_buf
|
/// [`poll_read_buf`]: #method.poll_read_buf
|
||||||
unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [u8]) -> bool {
|
unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [u8]) -> bool {
|
||||||
for i in 0..buf.len() {
|
for i in 0..buf.len() {
|
||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
|
@ -14,17 +14,17 @@ use std::task::{Context, Poll};
|
|||||||
/// Specifically, this means that the `poll_write` function will return one of
|
/// Specifically, this means that the `poll_write` function will return one of
|
||||||
/// the following:
|
/// the following:
|
||||||
///
|
///
|
||||||
/// * `Ok(Async::Ready(n))` means that `n` bytes of data was immediately
|
/// * `Poll::Ready(Ok(n))` means that `n` bytes of data was immediately
|
||||||
/// written.
|
/// written.
|
||||||
///
|
///
|
||||||
/// * `Ok(Async::NotReady)` means that no data was written from the buffer
|
/// * `Poll::Pending` means that no data was written from the buffer
|
||||||
/// provided. The I/O object is not currently writable but may become writable
|
/// provided. The I/O object is not currently writable but may become writable
|
||||||
/// in the future. Most importantly, **the current future's task is scheduled
|
/// in the future. Most importantly, **the current future's task is scheduled
|
||||||
/// to get unparked when the object is writable**. This means that like
|
/// to get unparked when the object is writable**. This means that like
|
||||||
/// `Future::poll` you'll receive a notification when the I/O object is
|
/// `Future::poll` you'll receive a notification when the I/O object is
|
||||||
/// writable again.
|
/// writable again.
|
||||||
///
|
///
|
||||||
/// * `Err(e)` for other errors are standard I/O errors coming from the
|
/// * `Poll::Ready(Err(e))` for other errors are standard I/O errors coming from the
|
||||||
/// underlying object.
|
/// underlying object.
|
||||||
///
|
///
|
||||||
/// This trait importantly means that the `write` method only works in the
|
/// This trait importantly means that the `write` method only works in the
|
||||||
@ -38,10 +38,10 @@ use std::task::{Context, Poll};
|
|||||||
pub trait AsyncWrite {
|
pub trait AsyncWrite {
|
||||||
/// Attempt to write bytes from `buf` into the object.
|
/// Attempt to write bytes from `buf` into the object.
|
||||||
///
|
///
|
||||||
/// On success, returns `Ok(Async::Ready(num_bytes_written))`.
|
/// On success, returns `Poll::Ready(Ok(num_bytes_written))`.
|
||||||
///
|
///
|
||||||
/// If the object is not ready for writing, the method returns
|
/// If the object is not ready for writing, the method returns
|
||||||
/// `Ok(Async::NotReady)` and arranges for the current task (via
|
/// `Poll::Pending` and arranges for the current task (via
|
||||||
/// `cx.waker()`) to receive a notification when the object becomes
|
/// `cx.waker()`) to receive a notification when the object becomes
|
||||||
/// readable or is closed.
|
/// readable or is closed.
|
||||||
fn poll_write(
|
fn poll_write(
|
||||||
@ -53,10 +53,10 @@ pub trait AsyncWrite {
|
|||||||
/// Attempt to flush the object, ensuring that any buffered data reach
|
/// Attempt to flush the object, ensuring that any buffered data reach
|
||||||
/// their destination.
|
/// their destination.
|
||||||
///
|
///
|
||||||
/// On success, returns `Ok(Async::Ready(()))`.
|
/// On success, returns `Poll::Ready(Ok(()))`.
|
||||||
///
|
///
|
||||||
/// If flushing cannot immediately complete, this method returns
|
/// If flushing cannot immediately complete, this method returns
|
||||||
/// `Ok(Async::NotReady)` and arranges for the current task (via
|
/// `Poll::Pending` and arranges for the current task (via
|
||||||
/// `cx.waker()`) to receive a notification when the object can make
|
/// `cx.waker()`) to receive a notification when the object can make
|
||||||
/// progress towards flushing.
|
/// progress towards flushing.
|
||||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>>;
|
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>>;
|
||||||
@ -89,21 +89,21 @@ pub trait AsyncWrite {
|
|||||||
///
|
///
|
||||||
/// # Return value
|
/// # Return value
|
||||||
///
|
///
|
||||||
/// This function returns a `Poll<(), io::Error>` classified as such:
|
/// This function returns a `Poll<io::Result<()>>` classified as such:
|
||||||
///
|
///
|
||||||
/// * `Ok(Async::Ready(()))` - indicates that the connection was
|
/// * `Poll::Ready(Ok(()))` - indicates that the connection was
|
||||||
/// successfully shut down and is now safe to deallocate/drop/close
|
/// successfully shut down and is now safe to deallocate/drop/close
|
||||||
/// resources associated with it. This method means that the current task
|
/// resources associated with it. This method means that the current task
|
||||||
/// will no longer receive any notifications due to this method and the
|
/// will no longer receive any notifications due to this method and the
|
||||||
/// I/O object itself is likely no longer usable.
|
/// I/O object itself is likely no longer usable.
|
||||||
///
|
///
|
||||||
/// * `Ok(Async::NotReady)` - indicates that shutdown is initiated but could
|
/// * `Poll::Pending` - indicates that shutdown is initiated but could
|
||||||
/// not complete just yet. This may mean that more I/O needs to happen to
|
/// not complete just yet. This may mean that more I/O needs to happen to
|
||||||
/// continue this shutdown operation. The current task is scheduled to
|
/// continue this shutdown operation. The current task is scheduled to
|
||||||
/// receive a notification when it's otherwise ready to continue the
|
/// receive a notification when it's otherwise ready to continue the
|
||||||
/// shutdown operation. When woken up this method should be called again.
|
/// shutdown operation. When woken up this method should be called again.
|
||||||
///
|
///
|
||||||
/// * `Err(e)` - indicates a fatal error has happened with shutdown,
|
/// * `Poll::Ready(Err(e))` - indicates a fatal error has happened with shutdown,
|
||||||
/// indicating that the shutdown operation did not complete successfully.
|
/// indicating that the shutdown operation did not complete successfully.
|
||||||
/// This typically means that the I/O object is no longer usable.
|
/// This typically means that the I/O object is no longer usable.
|
||||||
///
|
///
|
||||||
|
@ -52,5 +52,5 @@ pub use tokio_fs::{stderr, stdin, stdout, Stderr, Stdin, Stdout};
|
|||||||
pub use tokio_io::{AsyncRead, AsyncWrite};
|
pub use tokio_io::{AsyncRead, AsyncWrite};
|
||||||
|
|
||||||
// Re-export io::Error so that users don't have to deal
|
// Re-export io::Error so that users don't have to deal
|
||||||
// with conflicts when `use`ing `futures::io` and `std::io`.
|
// with conflicts when `use`ing `tokio::io` and `std::io`.
|
||||||
pub use std::io::{Error, ErrorKind, Result};
|
pub use std::io::{Error, ErrorKind, Result};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user