mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-07 00:00:08 +02:00
Merge pull request #272 from cramertj/must-use
Set Future types as must_use
This commit is contained in:
@@ -23,6 +23,7 @@ use reactor::{Handle, PollEvented};
|
|||||||
/// This type is created by the [`channel`] function.
|
/// This type is created by the [`channel`] function.
|
||||||
///
|
///
|
||||||
/// [`channel`]: fn.channel.html
|
/// [`channel`]: fn.channel.html
|
||||||
|
#[must_use = "sinks do nothing unless polled"]
|
||||||
pub struct Sender<T> {
|
pub struct Sender<T> {
|
||||||
tx: channel::Sender<T>,
|
tx: channel::Sender<T>,
|
||||||
}
|
}
|
||||||
@@ -37,6 +38,7 @@ pub struct Sender<T> {
|
|||||||
/// `Stream` trait to represent received messages.
|
/// `Stream` trait to represent received messages.
|
||||||
///
|
///
|
||||||
/// [`channel`]: fn.channel.html
|
/// [`channel`]: fn.channel.html
|
||||||
|
#[must_use = "streams do nothing unless polled"]
|
||||||
pub struct Receiver<T> {
|
pub struct Receiver<T> {
|
||||||
rx: PollEvented<channel::Receiver<T>>,
|
rx: PollEvented<channel::Receiver<T>>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use futures::{Future, Poll};
|
|||||||
/// bytes copied or an error if one happens.
|
/// bytes copied or an error if one happens.
|
||||||
///
|
///
|
||||||
/// [`copy`]: fn.copy.html
|
/// [`copy`]: fn.copy.html
|
||||||
|
#[must_use = "futures do nothing unless polled"]
|
||||||
pub struct Copy<R, W> {
|
pub struct Copy<R, W> {
|
||||||
reader: R,
|
reader: R,
|
||||||
read_done: bool,
|
read_done: bool,
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use futures::{Poll, Future, Async};
|
|||||||
/// Created by the [`flush`] function.
|
/// Created by the [`flush`] function.
|
||||||
///
|
///
|
||||||
/// [`flush`]: fn.flush.html
|
/// [`flush`]: fn.flush.html
|
||||||
|
#[must_use = "futures do nothing unless polled"]
|
||||||
pub struct Flush<A> {
|
pub struct Flush<A> {
|
||||||
a: Option<A>,
|
a: Option<A>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -310,6 +310,7 @@ pub trait Codec {
|
|||||||
/// the `Codec` trait to encode and decode frames.
|
/// the `Codec` trait to encode and decode frames.
|
||||||
///
|
///
|
||||||
/// You can acquire a `Framed` instance by using the `Io::framed` adapter.
|
/// You can acquire a `Framed` instance by using the `Io::framed` adapter.
|
||||||
|
#[must_use = "streams do nothing unless polled"]
|
||||||
pub struct Framed<T, C> {
|
pub struct Framed<T, C> {
|
||||||
upstream: T,
|
upstream: T,
|
||||||
codec: C,
|
codec: C,
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ pub fn read<R, T>(rd: R, buf: T) -> Read<R, T>
|
|||||||
/// a buffer.
|
/// a buffer.
|
||||||
///
|
///
|
||||||
/// Created by the [`read`] function.
|
/// Created by the [`read`] function.
|
||||||
|
#[must_use = "futures do nothing unless polled"]
|
||||||
pub struct Read<R, T> {
|
pub struct Read<R, T> {
|
||||||
state: State<R, T>,
|
state: State<R, T>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use futures::{Poll, Future};
|
|||||||
/// Created by the [`read_exact`] function.
|
/// Created by the [`read_exact`] function.
|
||||||
///
|
///
|
||||||
/// [`read_exact`]: fn.read_exact.html
|
/// [`read_exact`]: fn.read_exact.html
|
||||||
|
#[must_use = "futures do nothing unless polled"]
|
||||||
pub struct ReadExact<A, T> {
|
pub struct ReadExact<A, T> {
|
||||||
state: State<A, T>,
|
state: State<A, T>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use futures::{Poll, Future};
|
|||||||
/// Created by the [`read_to_end`] function.
|
/// Created by the [`read_to_end`] function.
|
||||||
///
|
///
|
||||||
/// [`read_to_end`]: fn.read_to_end.html
|
/// [`read_to_end`]: fn.read_to_end.html
|
||||||
|
#[must_use = "futures do nothing unless polled"]
|
||||||
pub struct ReadToEnd<A> {
|
pub struct ReadToEnd<A> {
|
||||||
state: State<A>,
|
state: State<A>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use futures::{Poll, Future};
|
|||||||
/// Created by the [`read_until`] function.
|
/// Created by the [`read_until`] function.
|
||||||
///
|
///
|
||||||
/// [`read_until`]: fn.read_until.html
|
/// [`read_until`]: fn.read_until.html
|
||||||
|
#[must_use = "futures do nothing unless polled"]
|
||||||
pub struct ReadUntil<A> {
|
pub struct ReadUntil<A> {
|
||||||
state: State<A>,
|
state: State<A>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use futures::{Poll, Future};
|
|||||||
/// This is created by the [`write_all`] top-level method.
|
/// This is created by the [`write_all`] top-level method.
|
||||||
///
|
///
|
||||||
/// [`write_all`]: fn.write_all.html
|
/// [`write_all`]: fn.write_all.html
|
||||||
|
#[must_use = "futures do nothing unless polled"]
|
||||||
pub struct WriteAll<A, T> {
|
pub struct WriteAll<A, T> {
|
||||||
state: State<A, T>,
|
state: State<A, T>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ pub struct TcpListener {
|
|||||||
|
|
||||||
/// Stream returned by the `TcpListener::incoming` function representing the
|
/// Stream returned by the `TcpListener::incoming` function representing the
|
||||||
/// stream of sockets received from a listener.
|
/// stream of sockets received from a listener.
|
||||||
|
#[must_use = "streams do nothing unless polled"]
|
||||||
pub struct Incoming {
|
pub struct Incoming {
|
||||||
inner: TcpListener,
|
inner: TcpListener,
|
||||||
}
|
}
|
||||||
@@ -235,10 +236,12 @@ pub struct TcpStream {
|
|||||||
|
|
||||||
/// Future returned by `TcpStream::connect` which will resolve to a `TcpStream`
|
/// Future returned by `TcpStream::connect` which will resolve to a `TcpStream`
|
||||||
/// when the stream is connected.
|
/// when the stream is connected.
|
||||||
|
#[must_use = "futures do nothing unless polled"]
|
||||||
pub struct TcpStreamNew {
|
pub struct TcpStreamNew {
|
||||||
inner: TcpStreamNewState,
|
inner: TcpStreamNewState,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use = "futures do nothing unless polled"]
|
||||||
enum TcpStreamNewState {
|
enum TcpStreamNewState {
|
||||||
Waiting(TcpStream),
|
Waiting(TcpStream),
|
||||||
Error(io::Error),
|
Error(io::Error),
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ pub trait UdpCodec {
|
|||||||
///
|
///
|
||||||
/// You can acquire a `UdpFramed` instance by using the `UdpSocket::framed`
|
/// You can acquire a `UdpFramed` instance by using the `UdpSocket::framed`
|
||||||
/// adapter.
|
/// adapter.
|
||||||
|
#[must_use = "sinks do nothing unless polled"]
|
||||||
pub struct UdpFramed<C> {
|
pub struct UdpFramed<C> {
|
||||||
socket: UdpSocket,
|
socket: UdpSocket,
|
||||||
codec: C,
|
codec: C,
|
||||||
|
|||||||
@@ -394,6 +394,7 @@ impl fmt::Debug for UdpSocket {
|
|||||||
/// A future used to write the entire contents of some data to a UDP socket.
|
/// A future used to write the entire contents of some data to a UDP socket.
|
||||||
///
|
///
|
||||||
/// This is created by the `UdpSocket::send_dgram` method.
|
/// This is created by the `UdpSocket::send_dgram` method.
|
||||||
|
#[must_use = "futures do nothing unless polled"]
|
||||||
pub struct SendDgram<T> {
|
pub struct SendDgram<T> {
|
||||||
state: SendState<T>,
|
state: SendState<T>,
|
||||||
}
|
}
|
||||||
@@ -441,6 +442,7 @@ impl<T> Future for SendDgram<T>
|
|||||||
/// A future used to receive a datagram from a UDP socket.
|
/// A future used to receive a datagram from a UDP socket.
|
||||||
///
|
///
|
||||||
/// This is created by the `UdpSocket::recv_dgram` method.
|
/// This is created by the `UdpSocket::recv_dgram` method.
|
||||||
|
#[must_use = "futures do nothing unless polled"]
|
||||||
pub struct RecvDgram<T> {
|
pub struct RecvDgram<T> {
|
||||||
state: RecvState<T>,
|
state: RecvState<T>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ use reactor::timeout_token::TimeoutToken;
|
|||||||
/// Note that timeouts are not intended for high resolution timers, but rather
|
/// Note that timeouts are not intended for high resolution timers, but rather
|
||||||
/// they will likely fire some granularity after the exact instant that they're
|
/// they will likely fire some granularity after the exact instant that they're
|
||||||
/// otherwise indicated to fire at.
|
/// otherwise indicated to fire at.
|
||||||
|
#[must_use = "streams do nothing unless polled"]
|
||||||
pub struct Interval {
|
pub struct Interval {
|
||||||
token: TimeoutToken,
|
token: TimeoutToken,
|
||||||
next: Instant,
|
next: Instant,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ use reactor::timeout_token::TimeoutToken;
|
|||||||
/// Note that timeouts are not intended for high resolution timers, but rather
|
/// Note that timeouts are not intended for high resolution timers, but rather
|
||||||
/// they will likely fire some granularity after the exact instant that they're
|
/// they will likely fire some granularity after the exact instant that they're
|
||||||
/// otherwise indicated to fire at.
|
/// otherwise indicated to fire at.
|
||||||
|
#[must_use = "futures do nothing unless polled"]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Timeout {
|
pub struct Timeout {
|
||||||
token: TimeoutToken,
|
token: TimeoutToken,
|
||||||
|
|||||||
Reference in New Issue
Block a user