pub struct Connector<S: ToSocketAddrs + Clone, V: Into<String> + Clone> { /* private fields */ }Expand description
A builder for creating and establishing STOMP connections to a server
This struct provides a builder pattern for configuring the connection parameters and then connecting to a STOMP server.
§Examples
use async_stomp::client::Connector;
#[tokio::main]
async fn main() {
let connection = Connector::builder()
.server("stomp.example.com")
.virtualhost("stomp.example.com")
.login("guest".to_string())
.passcode("guest".to_string())
.connect()
.await;
}Implementations§
Source§impl<S: ToSocketAddrs + Clone, V: Into<String> + Clone> Connector<S, V>
impl<S: ToSocketAddrs + Clone, V: Into<String> + Clone> Connector<S, V>
Sourcepub fn builder() -> ConnectorBuilder<S, V, ((), (), (), (), (), (), ())>
pub fn builder() -> ConnectorBuilder<S, V, ((), (), (), (), (), (), ())>
Create a builder for building Connector.
On the builder, call .server(...), .virtualhost(...), .login(...)(optional), .passcode(...)(optional), .headers(...)(optional), .use_tls(...)(optional), .tls_server_name(...)(optional) to set the values of the fields.
Finally, call .__build() to create the instance of Connector.
Source§impl<S: ToSocketAddrs + Clone, V: Into<String> + Clone> Connector<S, V>
impl<S: ToSocketAddrs + Clone, V: Into<String> + Clone> Connector<S, V>
Sourcepub async fn connect(self) -> Result<ClientTransport, Error>
pub async fn connect(self) -> Result<ClientTransport, Error>
Connect to the STOMP server using the configured parameters
This method establishes a connection to the STOMP server and performs the STOMP protocol handshake. If successful, it returns a ClientTransport that can be used to send and receive STOMP messages.