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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
use futures::{Future, Poll};
use lapin::{Connect as LapinConnect, Connection, ConnectionPromise, Result};
use crate::{
tcp::Identity, uri::AMQPUri, Channel, ConfirmationFuture, ConnectionProperties, Error,
};
#[derive(Clone)]
#[deprecated(note = "use lapin instead")]
pub struct Client {
conn: Connection,
}
impl Client {
#[deprecated(note = "use lapin instead")]
pub fn connect(uri: &str, options: ConnectionProperties) -> ClientFuture {
Connect::connect(uri, options, None)
}
#[deprecated(note = "use lapin instead")]
pub fn connect_with_identity(
uri: &str,
options: ConnectionProperties,
identity: Identity<'_, '_>,
) -> ClientFuture {
Connect::connect(uri, options, Some(identity))
}
#[deprecated(note = "use lapin instead")]
pub fn connect_uri(uri: AMQPUri, options: ConnectionProperties) -> ClientFuture {
Connect::connect(uri, options, None)
}
#[deprecated(note = "use lapin instead")]
pub fn connect_uri_with_identity(
uri: AMQPUri,
options: ConnectionProperties,
identity: Identity<'_, '_>,
) -> ClientFuture {
Connect::connect(uri, options, Some(identity))
}
#[deprecated(note = "use lapin instead")]
pub fn create_channel(&self) -> impl Future<Item = Channel, Error = Error> + Send + 'static {
Channel::create(&self.conn)
}
#[deprecated(note = "use lapin instead")]
pub fn update_secret(&self, new_secret: &str, reason: &str) -> ConfirmationFuture<()> {
self.conn.update_secret(new_secret, reason).into()
}
#[deprecated(note = "use lapin instead")]
pub fn block(&self, reason: &str) -> ConfirmationFuture<()> {
self.conn.block(reason).into()
}
#[deprecated(note = "use lapin instead")]
pub fn unblock(&self) -> ConfirmationFuture<()> {
self.conn.unblock().into()
}
#[deprecated(note = "use lapin instead")]
pub fn on_error<E: Fn(Error) + Send + 'static>(&self, handler: Box<E>) {
self.conn.on_error(handler);
}
}
#[deprecated(note = "use lapin instead")]
pub struct ClientFuture(ConfirmationFuture<Connection, Result<()>>);
impl Future for ClientFuture {
type Item = Client;
type Error = Error;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
Ok(self.0.poll()?.map(|conn| Client { conn }))
}
}
impl From<ConnectionPromise> for ClientFuture {
fn from(promise: ConnectionPromise) -> Self {
Self(promise.into())
}
}
#[deprecated(note = "use lapin instead")]
pub trait Connect {
fn connect(
self,
options: ConnectionProperties,
identity: Option<Identity<'_, '_>>,
) -> ClientFuture;
}
impl Connect for AMQPUri {
fn connect(
self,
options: ConnectionProperties,
identity: Option<Identity<'_, '_>>,
) -> ClientFuture {
LapinConnect::connect(self, options, identity).into()
}
}
impl Connect for &str {
fn connect(
self,
options: ConnectionProperties,
identity: Option<Identity<'_, '_>>,
) -> ClientFuture {
LapinConnect::connect(self, options, identity).into()
}
}