pub struct Connect<T> { /* private fields */ }Expand description
Request to resolve and connect to a remote address.
A request owns one list of pre-resolved addresses. It starts with
Address::addr() of the original value, if any, and is replaced by
set_addr() or set_addrs(), emptied by
clear_addrs() or take_addrs(), and
filled by the resolver when empty. The connector connects to exactly the
addresses reported by addrs().
Implementations§
Source§impl<T: Address> Connect<T>
impl<T: Address> Connect<T>
Sourcepub fn new(req: T) -> Connect<T>
pub fn new(req: T) -> Connect<T>
Creates a connection request and derives a port from the host when present.
A pre-resolved Address::addr() becomes the request’s initial
address, and provides the port if the host has none.
Sourcepub fn with(req: T, addr: SocketAddr) -> Connect<T>
pub fn with(req: T, addr: SocketAddr) -> Connect<T>
Creates a request with a pre-resolved socket address.
The address replaces any Address::addr() of req, and the connector
skips DNS resolution for this request.
Sourcepub fn set_port(self, port: u16) -> Self
pub fn set_port(self, port: u16) -> Self
Sets the port used when Address::port() does not provide one.
This replaces the port parsed from a host:port host by
new(), which is zero if the host has none.
Sourcepub fn set_addr(self, addr: Option<SocketAddr>) -> Self
pub fn set_addr(self, addr: Option<SocketAddr>) -> Self
Replaces the pre-resolved addresses with addr.
None keeps the current addresses, use
clear_addrs() to remove them.
Sourcepub fn set_addrs<I>(self, addrs: I) -> Selfwhere
I: IntoIterator<Item = SocketAddr>,
pub fn set_addrs<I>(self, addrs: I) -> Selfwhere
I: IntoIterator<Item = SocketAddr>,
Replaces the pre-resolved addresses with addrs.
An empty iterator removes all addresses, like
clear_addrs().
Sourcepub fn clear_addrs(self) -> Self
pub fn clear_addrs(self) -> Self
Removes all pre-resolved addresses, including the initial
Address::addr().
The connector then resolves host() instead.
Sourcepub fn port(&self) -> u16
pub fn port(&self) -> u16
Returns the port from Address::port(), or the one parsed from the
host or set by set_port().
Sourcepub fn addrs(&self) -> ConnectAddrsIter<'_>
pub fn addrs(&self) -> ConnectAddrsIter<'_>
Iterates over the request’s pre-resolved addresses.
Sourcepub fn take_addrs(&mut self) -> ConnectTakeAddrsIter
pub fn take_addrs(&mut self) -> ConnectTakeAddrsIter
Removes and returns the request’s pre-resolved addresses.
The request has no addresses afterwards, so a second call returns an empty iterator.
Sourcepub fn map_addr<F, R>(self, f: F) -> Connect<R>where
F: FnOnce(T) -> R,
pub fn map_addr<F, R>(self, f: F) -> Connect<R>where
F: FnOnce(T) -> R,
Maps the original address value while preserving port and resolved addresses.
Address::addr() of the new value is not used.
Trait Implementations§
impl<T: Eq> Eq for Connect<T>
Source§type Error = Error<ConnectError>
type Error = Error<ConnectError>
Source§async fn call(
&self,
req: Connect<A>,
ctx: Ctx<'_, Self, SharedCfg>,
) -> Result<Io, Self::Error>
async fn call( &self, req: Connect<A>, ctx: Ctx<'_, Self, SharedCfg>, ) -> Result<Io, Self::Error>
§fn ready(
&self,
ctx: Ctx<'_, Self, St>,
) -> impl Future<Output = Result<(), Self::Error>>
fn ready( &self, ctx: Ctx<'_, Self, St>, ) -> impl Future<Output = Result<(), Self::Error>>
§fn shutdown(&self, ctx: Ctx<'_, Self, St>) -> impl Future<Output = ()>
fn shutdown(&self, ctx: Ctx<'_, Self, St>) -> impl Future<Output = ()>
§fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, Self, Res>, St, Req>
fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, Self, Res>, St, Req>
§fn map_err<F, E>(self, f: F) -> ServiceChain<MapErr<F, Self, E>, St, Req>
fn map_err<F, E>(self, f: F) -> ServiceChain<MapErr<F, Self, E>, St, Req>
impl<T: PartialEq> StructuralPartialEq for Connect<T>
Auto Trait Implementations§
impl<T> Freeze for Connect<T>where
T: Freeze,
impl<T> RefUnwindSafe for Connect<T>where
T: RefUnwindSafe,
impl<T> Send for Connect<T>where
T: Send,
impl<T> Sync for Connect<T>where
T: Sync,
impl<T> Unpin for Connect<T>where
T: Unpin,
impl<T> UnsafeUnpin for Connect<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Connect<T>where
T: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.