1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use lapin::ConnectionProperties;

#[deprecated(note = "use tokio-executor-trait and tokio-reactor-trait directly instead")]
pub trait LapinTokioExt {
    #[deprecated(note = "use tokio-executor-trait and tokio-reactor-trait directly instead")]
    fn with_tokio(self) -> Self
    where
        Self: Sized,
    {
        let this = self.with_tokio_executor();
        #[cfg(unix)]
        let this = this.with_tokio_reactor();
        this
    }

    #[deprecated(note = "use tokio-executor-trait directly instead")]
    fn with_tokio_executor(self) -> Self
    where
        Self: Sized;

    #[cfg(unix)]
    #[deprecated(note = "use tokio-reactor-trait directly instead")]
    fn with_tokio_reactor(self) -> Self
    where
        Self: Sized;
}

impl LapinTokioExt for ConnectionProperties {
    fn with_tokio_executor(self) -> Self {
        self.with_executor(tokio_executor_trait::Tokio::current())
    }

    #[cfg(unix)]
    fn with_tokio_reactor(self) -> Self {
        self.with_reactor(tokio_reactor_trait::Tokio)
    }
}