pub struct OpenConnectionArguments { /* private fields */ }Expand description
The arguments used by Connection::open.
Methods can be chained in order to build the desired argument values, call
finish to finish chaining and returns a new argument.
Chaining configuration implies an additional clone when finish is called.
§Examples:
§Chaining configuration style
// Create a default and update only `credentials` field, then return desired config.
let args = OpenConnectionArguments::default()
.credentials(SecurityCredentials::new_amqplain("user", "bitnami"))
.finish();
// Create a new one and update the fields, then return desired config
let args = OpenConnectionArguments::new("localhost", 5672, "user", "bitnami")
.virtual_host("myhost")
.connection_name("myconnection")
.finish();§Non-chaining configuration style
// create a new and mutable argument
let mut args = OpenConnectionArguments::new("localhost", 5672, "user", "bitnami");
// update fields of the mutable argument
args.virtual_host("myhost").connection_name("myconnection");§Create from URI string if feature “urispec” is enabled
let args: OpenConnectionArguments = "amqp://user:bitnami@localhost".try_into().unwrap();
Implementations§
Source§impl OpenConnectionArguments
impl OpenConnectionArguments
Sourcepub fn new(host: &str, port: u16, username: &str, password: &str) -> Self
pub fn new(host: &str, port: u16, username: &str, password: &str) -> Self
Return a new argument with default configuration.
§Default
Use virtual host “/”, SASL/PLAIN authentication and auto generated connection name.
Sourcepub fn virtual_host(&mut self, virtual_host: &str) -> &mut Self
pub fn virtual_host(&mut self, virtual_host: &str) -> &mut Self
Sourcepub fn get_virtual_host(&self) -> &str
pub fn get_virtual_host(&self) -> &str
Get the virtual host of the server.
Sourcepub fn connection_name(&mut self, connection_name: &str) -> &mut Self
pub fn connection_name(&mut self, connection_name: &str) -> &mut Self
Sourcepub fn get_connection_name(&self) -> Option<&str>
pub fn get_connection_name(&self) -> Option<&str>
Get the connection name.
Sourcepub fn credentials(&mut self, credentials: SecurityCredentials) -> &mut Self
pub fn credentials(&mut self, credentials: SecurityCredentials) -> &mut Self
Set the user credentials. See RabbitMQ access control.
§Default
SASL/PLAIN authentication, “guest” as both username and password.
Sourcepub fn get_credentials(&self) -> &SecurityCredentials
pub fn get_credentials(&self) -> &SecurityCredentials
Get the credentials.
Sourcepub fn get_heartbeat(&self) -> u16
pub fn get_heartbeat(&self) -> u16
Get the heartbeat.
Sourcepub fn get_scheme(&self) -> Option<&str>
pub fn get_scheme(&self) -> Option<&str>
Get the connection scheme.
Sourcepub fn tls_adaptor(&mut self, tls_adaptor: TlsAdaptor) -> &mut Self
pub fn tls_adaptor(&mut self, tls_adaptor: TlsAdaptor) -> &mut Self
Sourcepub fn get_tls_adaptor(&self) -> Option<&TlsAdaptor>
pub fn get_tls_adaptor(&self) -> Option<&TlsAdaptor>
Get the TLS adaptor.
Trait Implementations§
Source§impl Clone for OpenConnectionArguments
impl Clone for OpenConnectionArguments
Source§fn clone(&self) -> OpenConnectionArguments
fn clone(&self) -> OpenConnectionArguments
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for OpenConnectionArguments
impl Default for OpenConnectionArguments
Source§impl TryFrom<&str> for OpenConnectionArguments
Available on crate feature urispec only.
impl TryFrom<&str> for OpenConnectionArguments
urispec only.Source§fn try_from(uri: &str) -> Result<Self, Error>
fn try_from(uri: &str) -> Result<Self, Error>
Create a new OpenConnectionArguments from a URI &str. Mostly follows the AMQP URI spec. See below for exceptions.
If the URI is invalid, a UriError error is returned.
If no port is specified, the default port of 5672 is used (as per the spec). If no host is speecified or is zero-length, a UriError error is returned. Note that this is different from the spec, which allows for EmptyHost. This is because the host is used to create a TCP connection, and an empty host is invalid.