Enum ns_router::AutoName [] [src]

pub enum AutoName<'a> {
    Auto(&'a str),
    HostPort(&'a stru16),
    HostDefaultPort(&'a str),
    Service(&'a str),
    IpAddr(IpAddr),
    SocketAddr(SocketAddr),
}

A name type that can be read from config

The core idea of AutoName is that for service with default port 80 (HTTP) we treat names the following way:

  • example.org → A record example.org, port 80
  • example.org:8080 → A record example.org, port 8080
  • _service._proto.example.org → SRV record, and port from the record
  • 127.0.0.1 → IP used directly, port 80
  • 127.0.0.1:8080 → IP/port used directly
  • 2001:db8::2:1 → IPv6 address (note: no brackets)
  • [2001:db8::2:1]:1235 → IPv6 address and port (note: square brackets)

This works by wrapping the string read from configuration file into AutoName::Auto and using it in Router. You might override things via configuration specific things, for example in yaml you might want to write:

addresses:
- !Srv myservice.query.consul

... And convert it into Service("myservice.query.consul") which will be resolved using SRV record (or similar mechanism) instead of using hostname (i.e. standard expects using _service._proto prefix but does not requires that).

Variants

Auto-determine how to treat the name

Resolve host and attach specified port

Resolve host and attach default port to it

Use service name and port resolved using SRV record or similar

A bare IP used directly as a host

A bare socket address used directly as a service address

Trait Implementations

impl<'a> Debug for AutoName<'a>
[src]

[src]

Formats the value using the given formatter. Read more

impl<'a, T: AsRef<str> + 'a> From<&'a T> for AutoName<'a>
[src]

[src]

Performs the conversion.

impl<'a> From<&'a str> for AutoName<'a>
[src]

[src]

Performs the conversion.

Auto Trait Implementations

impl<'a> Send for AutoName<'a>

impl<'a> Sync for AutoName<'a>