pub struct Address { /* private fields */ }
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§
Source§impl Address
impl Address
Sourcepub fn new(
domain: &str,
port: u16,
authorization: Option<Authorization>,
) -> Self
pub fn new( domain: &str, port: u16, authorization: Option<Authorization>, ) -> Self
Create a new Address
Get the Address
’s Authorization
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Address
impl<'de> Deserialize<'de> for Address
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Address
Auto Trait Implementations§
impl Freeze for Address
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnwindSafe for Address
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more