Struct abstract_ns::addr::Address
[−]
[src]
pub struct Address(_);
Address that nameservice has returned
We hide this structure to allow future additions. There is Builder
which provides a forward compatible way to build such address in a resolver
and there are methods to extract data from it.
Internally it's an Arc
over a structure so it's cheap to clone and you
can cache addresses.
Methods
impl Address
[src]
fn pick_one(&self) -> Option<SocketAddr>
[src]
Select one random address to connect to
Picks a single address from the set of high priority addresses, with the random distribution according to the weights.
This method is stateless so it can't find out that high priority addresses are all inaccessible and fallback addresses should be used.
Returns None
if address is empty
fn addresses_at(&self, priority: usize) -> OwnedAddressIter
[src]
Returns an owned iterator over addresses at priority
This is similar to self.at(pri).addresses()
but returns an owned
object that implements IntoIterator. This might be useful for streams
and futures where borrowed objects don't work
fn at(&self, priority: usize) -> WeightedSet
[src]
Returns the set of the hosts for the same priority
Note: original priorities are lost. This method has contiguous array
of sets of hosts. The highest priority hosts returned by .at(0)
.
If no hosts the priority exists returns an empty set
Use iter()
to iterate over WeightedSet
's by priority
fn iter(&self) -> PriorityIter
[src]
Returns iterator over WeightedSet
's starting from high priority set
fn parse_list<I>(iter: I) -> Result<Address, AddrParseError> where
I: IntoIterator,
I::Item: AsRef<str>,
[src]
I: IntoIterator,
I::Item: AsRef<str>,
Parse a list of strings and put it into an address
This only uses one layer of addresses with same weights. And is mostly useful for unit tests
Trait Implementations
impl Clone for Address
[src]
fn clone(&self) -> Address
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Address
[src]
impl From<(IpAddr, u16)> for Address
[src]
impl From<SocketAddr> for Address
[src]
fn from(addr: SocketAddr) -> Address
[src]
Performs the conversion.
impl<'a> From<&'a [SocketAddr]> for Address
[src]
impl FromIterator<SocketAddr> for Address
[src]
fn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = SocketAddr>,
[src]
T: IntoIterator<Item = SocketAddr>,
Creates a value from an iterator. Read more
impl AsRef<Address> for Address
[src]
impl PartialEq for Address
[src]
fn eq(&self, other: &Address) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.