mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-15 02:51:25 +00:00
add must_use for Future (#450)
This commit is contained in:
committed by
Toralf Wittner
parent
02576eecf1
commit
ee9be6f0c9
@ -562,6 +562,7 @@ where
|
||||
}
|
||||
|
||||
/// Implementation of `Future` that yields the next incoming substream from a dialed connection.
|
||||
#[must_use = "futures do nothing unless polled"]
|
||||
pub struct ConnectionReuseIncoming<T, D, M>
|
||||
where
|
||||
T: Transport,
|
||||
|
@ -213,6 +213,7 @@ where
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[must_use = "futures do nothing unless polled"]
|
||||
pub enum EitherOutbound<A: StreamMuxer, B: StreamMuxer> {
|
||||
A(A::OutboundSubstream),
|
||||
B(B::OutboundSubstream),
|
||||
@ -220,6 +221,7 @@ pub enum EitherOutbound<A: StreamMuxer, B: StreamMuxer> {
|
||||
|
||||
/// Implements `Stream` and dispatches all method calls to either `First` or `Second`.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[must_use = "futures do nothing unless polled"]
|
||||
pub enum EitherListenStream<A, B> {
|
||||
First(A),
|
||||
Second(B),
|
||||
@ -248,6 +250,7 @@ where
|
||||
// If Rust had impl Trait we could use the Either enum from the futures crate and add some
|
||||
// modifiers to it. This custom enum is a combination of Either and these modifiers.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[must_use = "futures do nothing unless polled"]
|
||||
pub enum EitherListenUpgrade<A, B> {
|
||||
First(A),
|
||||
Second(B),
|
||||
|
@ -222,6 +222,7 @@ where
|
||||
}
|
||||
|
||||
/// Future that must be driven to completion in order for the swarm to work.
|
||||
#[must_use = "futures do nothing unless polled"]
|
||||
pub struct SwarmFuture<T, H>
|
||||
where
|
||||
T: MuxedTransport + 'static, // TODO: 'static :-/
|
||||
|
@ -96,6 +96,7 @@ pub struct Interrupt {
|
||||
_tx: oneshot::Sender<()>,
|
||||
}
|
||||
|
||||
#[must_use = "futures do nothing unless polled"]
|
||||
pub struct InterruptibleDial<F> {
|
||||
inner: F,
|
||||
rx: future::Shared<oneshot::Receiver<()>>,
|
||||
|
@ -342,6 +342,7 @@ impl<T> Drop for UniqueConnec<T> {
|
||||
}
|
||||
|
||||
/// Future returned by `UniqueConnec::dial()`.
|
||||
#[must_use = "futures do nothing unless polled"]
|
||||
pub struct UniqueConnecFuture<T> {
|
||||
inner: Weak<Mutex<UniqueConnecInner<T>>>,
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ pub enum EitherUpgradeIdentifier<A, B> {
|
||||
// If Rust had impl Trait we could use the Either enum from the futures crate and add some
|
||||
// modifiers to it. This custom enum is a combination of Either and these modifiers.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[must_use = "futures do nothing unless polled"]
|
||||
pub enum EitherConnUpgrFuture<A, B> {
|
||||
First(A),
|
||||
Second(B),
|
||||
|
@ -519,6 +519,7 @@ pub struct Message {
|
||||
}
|
||||
|
||||
/// Implementation of `Future` that must be driven to completion in order for floodsub to work.
|
||||
#[must_use = "futures do nothing unless polled"]
|
||||
pub struct FloodSubFuture {
|
||||
inner: Box<Future<Item = (), Error = IoError>>,
|
||||
}
|
||||
|
@ -135,6 +135,7 @@ impl<T: Transport> Stream for Listener<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use = "futures do nothing unless polled"]
|
||||
pub struct ListenerUpgrade<T: Transport>(RateLimited<T::ListenerUpgrade>);
|
||||
|
||||
impl<T> Future for ListenerUpgrade<T>
|
||||
|
@ -37,6 +37,7 @@ use tokio_io::{AsyncRead, AsyncWrite};
|
||||
///
|
||||
/// [`copy`]: fn.copy.html
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless polled"]
|
||||
pub struct Copy<R, W> {
|
||||
reader: Option<R>,
|
||||
read_done: bool,
|
||||
|
@ -192,6 +192,7 @@ fn multiaddr_to_socketaddr(addr: &Multiaddr) -> Result<SocketAddr, ()> {
|
||||
|
||||
/// Future that dials a TCP/IP address.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless polled"]
|
||||
pub struct TcpDialFut {
|
||||
inner: ConnectFuture,
|
||||
/// Address we're dialing. Extracted when the `Future` finishes.
|
||||
|
@ -180,6 +180,7 @@ where
|
||||
|
||||
// TODO: can be removed and replaced with an `impl Future` once impl Trait is fully stable
|
||||
// in Rust (https://github.com/rust-lang/rust/issues/34511)
|
||||
#[must_use = "futures do nothing unless polled"]
|
||||
pub struct TimeoutIncoming<InnerFut> {
|
||||
inner: InnerFut,
|
||||
timeout: Duration,
|
||||
@ -204,6 +205,7 @@ where
|
||||
/// Wraps around a `Future`. Turns the error type from `TimeoutError<IoError>` to `IoError`.
|
||||
// TODO: can be replaced with `impl Future` once `impl Trait` are fully stable in Rust
|
||||
// (https://github.com/rust-lang/rust/issues/34511)
|
||||
#[must_use = "futures do nothing unless polled"]
|
||||
pub struct TokioTimerMapErr<InnerFut> {
|
||||
inner: InnerFut,
|
||||
}
|
||||
|
Reference in New Issue
Block a user