pub struct Producer { /* private fields */ }Implementations§
Source§impl Producer
impl Producer
Sourcepub fn connect(
addr: &SocketAddr,
handle: &Handle,
config: Config,
) -> Box<dyn Future<Item = Producer, Error = Error>>
pub fn connect( addr: &SocketAddr, handle: &Handle, config: Config, ) -> Box<dyn Future<Item = Producer, Error = Error>>
Establish a connection and send protocol version.
Examples found in repository?
examples/pub.rs (line 17)
11fn main() {
12 let mut core = Core::new().unwrap();
13 let handle = core.handle();
14
15 let addr = "127.0.0.1:4150".parse().unwrap();
16
17 let res = Producer::connect(&addr, &handle, Config::default())
18 .and_then(|conn| {
19 conn.publish("some_topic".into(), "some_message".into())
20 .and_then(move |response| {
21 println!("Response: {:?}", response);
22 Ok(())
23 })
24 });
25 core.run(res).unwrap();
26}More examples
examples/mpub.rs (line 21)
11fn main() {
12 let mut core = Core::new().unwrap();
13 let handle = core.handle();
14
15 let addr = "127.0.0.1:4150".parse().unwrap();
16
17 let mut messages: Vec<String> = Vec::new();
18 messages.push("First message".into());
19 messages.push("Second message".into());
20
21 let res = Producer::connect(&addr, &handle, Config::default())
22 .and_then(|conn| {
23 conn.mpublish("some_topic".into(), messages)
24 .and_then(move |response| {
25 println!("Response: {:?}", response);
26 Ok(())
27 })
28 });
29 core.run(res).unwrap();
30}Sourcepub fn publish(
&self,
topic: String,
message: String,
) -> Box<dyn Future<Item = Message<String, Body<Message, Error>>, Error = Error>>
pub fn publish( &self, topic: String, message: String, ) -> Box<dyn Future<Item = Message<String, Body<Message, Error>>, Error = Error>>
Examples found in repository?
examples/pub.rs (line 19)
11fn main() {
12 let mut core = Core::new().unwrap();
13 let handle = core.handle();
14
15 let addr = "127.0.0.1:4150".parse().unwrap();
16
17 let res = Producer::connect(&addr, &handle, Config::default())
18 .and_then(|conn| {
19 conn.publish("some_topic".into(), "some_message".into())
20 .and_then(move |response| {
21 println!("Response: {:?}", response);
22 Ok(())
23 })
24 });
25 core.run(res).unwrap();
26}Sourcepub fn mpublish(
&self,
topic: String,
messages: Vec<String>,
) -> Box<dyn Future<Item = Message<String, Body<Message, Error>>, Error = Error>>
pub fn mpublish( &self, topic: String, messages: Vec<String>, ) -> Box<dyn Future<Item = Message<String, Body<Message, Error>>, Error = Error>>
Examples found in repository?
examples/mpub.rs (line 23)
11fn main() {
12 let mut core = Core::new().unwrap();
13 let handle = core.handle();
14
15 let addr = "127.0.0.1:4150".parse().unwrap();
16
17 let mut messages: Vec<String> = Vec::new();
18 messages.push("First message".into());
19 messages.push("Second message".into());
20
21 let res = Producer::connect(&addr, &handle, Config::default())
22 .and_then(|conn| {
23 conn.mpublish("some_topic".into(), messages)
24 .and_then(move |response| {
25 println!("Response: {:?}", response);
26 Ok(())
27 })
28 });
29 core.run(res).unwrap();
30}pub fn dpublish( &self, topic: String, message: String, defer_time: i64, ) -> Box<dyn Future<Item = Message<String, Body<Message, Error>>, Error = Error>>
Auto Trait Implementations§
impl !Freeze for Producer
impl !RefUnwindSafe for Producer
impl !Sync for Producer
impl !UnwindSafe for Producer
impl Send for Producer
impl Unpin for Producer
impl UnsafeUnpin for Producer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more