Skip to main content

Producer

Struct Producer 

Source
pub struct Producer { /* private fields */ }

Implementations§

Source§

impl Producer

Source

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
Hide additional 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}
Source

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}
Source

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}
Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.