pub struct ResolvedAddrs { /* private fields */ }Expand description
Every address a name resolved to, in the order the resolver returned them.
Resolution used to end in .next(), which threw away everything after the
first candidate. That is enough for an ip:port literal, but a hostname with
several A/AAAA records — a relay behind round-robin DNS, or a dual-stack host
whose first record is an unreachable IPv6 address — resolved to one address
and then failed against it, with the working candidates never tried.
The dial loops below this were always able to try every address: both
each_addr and the uni-stream providers iterate a ToSocketAddrs and only
report the last error once every candidate has failed. They just never
received more than one. So this type is the whole of the fix: carry the list
to them, and they do the rest.
Guaranteed non-empty, so a caller never has to handle a resolution that succeeded with nothing in it. Cheap to clone — the addresses are shared, not copied — because every tunnel worker and every retry needs its own handle.
Implementations§
Source§impl ResolvedAddrs
impl ResolvedAddrs
Sourcepub fn from_candidates(addrs: Vec<SocketAddr>) -> Option<Self>
pub fn from_candidates(addrs: Vec<SocketAddr>) -> Option<Self>
Build from candidates already resolved elsewhere, rejecting an empty list.
For callers that resolve through another address trait — the tunnel
internals take a generic ToSocketAddrs at their public boundary — and
need the result in this non-empty form.
Sourcepub fn as_slice(&self) -> &[SocketAddr]
pub fn as_slice(&self) -> &[SocketAddr]
The candidates, for handing to each_addr or a ToSocketAddrs bound.
&[SocketAddr] is what both address traits in play accept, and it is
Copy, which the A: ToSocketAddrs + Copy bounds on the tunnel internals
require. A Vec is neither.
Sourcepub fn primary(&self) -> SocketAddr
pub fn primary(&self) -> SocketAddr
The first candidate.
For the places that genuinely need one address rather than a list: a
SocketAddr field on a status record, a preflight probe, a log line. Not
for dialling — that is what Self::as_slice is for.
Trait Implementations§
Source§impl Clone for ResolvedAddrs
impl Clone for ResolvedAddrs
Source§impl Debug for ResolvedAddrs
impl Debug for ResolvedAddrs
Source§impl Display for ResolvedAddrs
impl Display for ResolvedAddrs
impl Eq for ResolvedAddrs
Source§impl From<SocketAddr> for ResolvedAddrs
impl From<SocketAddr> for ResolvedAddrs
Source§fn from(addr: SocketAddr) -> Self
fn from(addr: SocketAddr) -> Self
Source§impl PartialEq for ResolvedAddrs
impl PartialEq for ResolvedAddrs
impl StructuralPartialEq for ResolvedAddrs
Auto Trait Implementations§
impl Freeze for ResolvedAddrs
impl RefUnwindSafe for ResolvedAddrs
impl Send for ResolvedAddrs
impl Sync for ResolvedAddrs
impl Unpin for ResolvedAddrs
impl UnsafeUnpin for ResolvedAddrs
impl UnwindSafe for ResolvedAddrs
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more