Struct Subscriber

Source
pub struct Subscriber<S: Into<String>, I: Into<String>> { /* private fields */ }
Expand description

Builder to create a Subscribe message with optional custom headers

This struct provides a builder pattern for configuring subscription parameters and creating a SUBSCRIBE message to send to a STOMP server.

§Examples

use futures::prelude::*;
use async_stomp::client::Connector;
use async_stomp::client::Subscriber;


#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
  let mut connection = Connector::builder()
    .server("stomp.example.com")
    .virtualhost("stomp.example.com")
    .login("guest".to_string())
    .passcode("guest".to_string())
    .headers(vec![("client-id".to_string(), "ClientTest".to_string())])
    .connect()
    .await.expect("Client connection");
   
  let subscribe_msg = Subscriber::builder()
    .destination("queue.test")
    .id("custom-subscriber-id")
    .subscribe();

  connection.send(subscribe_msg).await?;
  Ok(())
}

Implementations§

Source§

impl<S: Into<String>, I: Into<String>> Subscriber<S, I>

Source

pub fn builder() -> SubscriberBuilder<S, I, ((), (), ())>

Create a builder for building Subscriber. On the builder, call .destination(...), .id(...), .headers(...)(optional) to set the values of the fields. Finally, call .__build() to create the instance of Subscriber.

Source§

impl<S: Into<String>, I: Into<String>> Subscriber<S, I>

Source

pub fn subscribe(self) -> Message<ToServer>

Creates a SUBSCRIBE message using the configured parameters

This method returns a STOMP SUBSCRIBE message that can be sent to a server to create a subscription with the configured destination, ID, and headers.

Auto Trait Implementations§

§

impl<S, I> Freeze for Subscriber<S, I>
where S: Freeze, I: Freeze,

§

impl<S, I> RefUnwindSafe for Subscriber<S, I>

§

impl<S, I> Send for Subscriber<S, I>
where S: Send, I: Send,

§

impl<S, I> Sync for Subscriber<S, I>
where S: Sync, I: Sync,

§

impl<S, I> Unpin for Subscriber<S, I>
where S: Unpin, I: Unpin,

§

impl<S, I> UnwindSafe for Subscriber<S, I>
where S: UnwindSafe, I: UnwindSafe,

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.