Struct rants::Address[][src]

pub struct Address { /* fields omitted */ }
Expand description

An address used to connect to a NATS server

An Address consists of a domain, a port number, and an optional Authorization. The domain can simply be the string representation of an IP address or a true domain name that will be resolved through DNS.

The string representation of an Address can take the following forms:

  • nats://<username>:<password>@<domain>:<port>
  • nats://<token>@<domain>:<port>

The only required part of the address string is the <domain>. This makes the simplest address solely an IP address (eg 127.0.0.1). If no port is specified the default, port 4222, is used.

Note: When a client attempts to connect to the server at an address, the authorization specified by the address will always override the client’s Connect default authorization.

Example

use rants::Address;

let address = "nats://username:password@127.0.0.1:8080".parse::<Address>();
assert!(address.is_ok());
let address = "auth_token@1.2.3.4".parse::<Address>();
assert!(address.is_ok());
let address = "nats://auth_token@1.2.3.4:5780".parse::<Address>();
assert!(address.is_ok());

Implementations

Create a new Address

Get the Address’s domain

Get the Address’s port

Get the Address’s domain and port

Get the Address’s Authorization

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.