Skip to main content

OpenConnectionArguments

Struct OpenConnectionArguments 

Source
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

Source

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.

Source

pub fn host(&mut self, host: &str) -> &mut Self

Set the host of the server.

§Default

“localhost”

Source

pub fn get_host(&self) -> &str

Get the host of the server.

Source

pub fn port(&mut self, port: u16) -> &mut Self

Set the port of the server.

§Default

5672 by AMQP 0-9-1 spec.

Source

pub fn get_port(&self) -> u16

Get the port of the server.

Source

pub fn virtual_host(&mut self, virtual_host: &str) -> &mut Self

Set the virtual host. See RabbitMQ vhosts.

§Default

“/”

Source

pub fn get_virtual_host(&self) -> &str

Get the virtual host of the server.

Source

pub fn connection_name(&mut self, connection_name: &str) -> &mut Self

Set the connection name.

§Default

Name is auto generated.

Source

pub fn get_connection_name(&self) -> Option<&str>

Get the connection name.

Source

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.

Source

pub fn get_credentials(&self) -> &SecurityCredentials

Get the credentials.

Source

pub fn heartbeat(&mut self, heartbeat: u16) -> &mut Self

Set the heartbeat timeout in seconds. See RabbitMQ heartbeats.

§Default

60 seconds.

Source

pub fn get_heartbeat(&self) -> u16

Get the heartbeat.

Source

pub fn scheme(&mut self, scheme: &str) -> &mut Self

Set the URI scheme.

Source

pub fn get_scheme(&self) -> Option<&str>

Get the connection scheme.

Source

pub fn tls_adaptor(&mut self, tls_adaptor: TlsAdaptor) -> &mut Self

Set SSL/TLS adaptor. Set to enable SSL/TLS connection.

§Default

No SSL/TLS enabled

Source

pub fn get_tls_adaptor(&self) -> Option<&TlsAdaptor>

Get the TLS adaptor.

Source

pub fn finish(&mut self) -> Self

Finish chaining and returns a new argument according to chained configurations.

It actually clones the resulted configurations.

Trait Implementations§

Source§

impl Clone for OpenConnectionArguments

Source§

fn clone(&self) -> OpenConnectionArguments

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for OpenConnectionArguments

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl TryFrom<&str> for OpenConnectionArguments

Available on crate feature urispec only.
Source§

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.

Source§

type Error = Error

The type returned in the event of a conversion 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more