pub struct ConnectInfo<R> { /* private fields */ }
Available on crate feature
connect
only.Expand description
Connection request information.
May contain known/pre-resolved socket address(es) or a host that needs resolving with DNS.
Implementations§
Source§impl<R: Host> ConnectInfo<R>
impl<R: Host> ConnectInfo<R>
Sourcepub fn new(request: R) -> ConnectInfo<R>
pub fn new(request: R) -> ConnectInfo<R>
Constructs new connection info using a request.
Sourcepub fn with_addr(request: R, addr: SocketAddr) -> ConnectInfo<R>
pub fn with_addr(request: R, addr: SocketAddr) -> ConnectInfo<R>
Constructs new connection info from request and known socket address.
Since socket address is known, Connector
will skip the DNS
resolution step.
Sourcepub fn set_port(self, port: u16) -> Self
pub fn set_port(self, port: u16) -> Self
Set connection port.
If request provided a port, this will override it.
Sourcepub fn set_addr(self, addr: impl Into<Option<SocketAddr>>) -> Self
pub fn set_addr(self, addr: impl Into<Option<SocketAddr>>) -> Self
Set connection socket address.
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>,
Set list of addresses.
Sourcepub fn set_local_addr(self, addr: impl Into<IpAddr>) -> Self
pub fn set_local_addr(self, addr: impl Into<IpAddr>) -> Self
Set local address to connection with.
Useful in situations where the IP address bound to a particular network interface is known. This would make sure the socket is opened through that interface.
Sourcepub fn addrs(
&self,
) -> impl Iterator<Item = SocketAddr> + ExactSizeIterator + FusedIterator + Clone + Debug + '_
pub fn addrs( &self, ) -> impl Iterator<Item = SocketAddr> + ExactSizeIterator + FusedIterator + Clone + Debug + '_
Get borrowed iterator of resolved request addresses.
§Examples
let addr = SocketAddr::from(([127, 0, 0, 1], 4242));
let conn = ConnectInfo::new("localhost");
let mut addrs = conn.addrs();
assert!(addrs.next().is_none());
let conn = ConnectInfo::with_addr("localhost", addr);
let mut addrs = conn.addrs();
assert_eq!(addrs.next().unwrap(), addr);
Sourcepub fn take_addrs(
&mut self,
) -> impl Iterator<Item = SocketAddr> + ExactSizeIterator + FusedIterator + Clone + Debug + 'static
pub fn take_addrs( &mut self, ) -> impl Iterator<Item = SocketAddr> + ExactSizeIterator + FusedIterator + Clone + Debug + 'static
Take owned iterator resolved request addresses.
§Examples
let addr = SocketAddr::from(([127, 0, 0, 1], 4242));
let mut conn = ConnectInfo::new("localhost");
let mut addrs = conn.take_addrs();
assert!(addrs.next().is_none());
let mut conn = ConnectInfo::with_addr("localhost", addr);
let mut addrs = conn.take_addrs();
assert_eq!(addrs.next().unwrap(), addr);
Trait Implementations§
Source§impl<R: Debug> Debug for ConnectInfo<R>
impl<R: Debug> Debug for ConnectInfo<R>
Source§impl<R: Host> Display for ConnectInfo<R>
impl<R: Host> Display for ConnectInfo<R>
Source§impl<R: Host> From<R> for ConnectInfo<R>
impl<R: Host> From<R> for ConnectInfo<R>
Source§impl<R: Hash> Hash for ConnectInfo<R>
impl<R: Hash> Hash for ConnectInfo<R>
Source§impl<R: PartialEq> PartialEq for ConnectInfo<R>
impl<R: PartialEq> PartialEq for ConnectInfo<R>
Source§impl<R: Host> Service<ConnectInfo<R>> for ConnectorService
impl<R: Host> Service<ConnectInfo<R>> for ConnectorService
Source§type Response = Connection<R, TcpStream>
type Response = Connection<R, TcpStream>
Responses given by the service.
Source§type Error = ConnectError
type Error = ConnectError
Errors produced by the service when polling readiness or executing call.
Source§impl<R: Host> Service<ConnectInfo<R>> for ResolverService
impl<R: Host> Service<ConnectInfo<R>> for ResolverService
Source§type Response = ConnectInfo<R>
type Response = ConnectInfo<R>
Responses given by the service.
Source§type Error = ConnectError
type Error = ConnectError
Errors produced by the service when polling readiness or executing call.
Source§impl<R: Host> Service<ConnectInfo<R>> for TcpConnectorService
impl<R: Host> Service<ConnectInfo<R>> for TcpConnectorService
Source§type Response = Connection<R, TcpStream>
type Response = Connection<R, TcpStream>
Responses given by the service.
Source§type Error = ConnectError
type Error = ConnectError
Errors produced by the service when polling readiness or executing call.
Source§impl<R: Host> ServiceFactory<ConnectInfo<R>> for Connector
impl<R: Host> ServiceFactory<ConnectInfo<R>> for Connector
Source§type Response = Connection<R, TcpStream>
type Response = Connection<R, TcpStream>
Responses given by the created services.
Source§type Error = ConnectError
type Error = ConnectError
Errors produced by the created services.
Source§type Service = ConnectorService
type Service = ConnectorService
The kind of
Service
created by this factory.Source§type Future = Ready<Result<<Connector as ServiceFactory<ConnectInfo<R>>>::Service, <Connector as ServiceFactory<ConnectInfo<R>>>::InitError>>
type Future = Ready<Result<<Connector as ServiceFactory<ConnectInfo<R>>>::Service, <Connector as ServiceFactory<ConnectInfo<R>>>::InitError>>
The future of the
Service
instance.gSource§fn new_service(&self, _: ()) -> Self::Future
fn new_service(&self, _: ()) -> Self::Future
Create and return a new service asynchronously.
Source§impl<R: Host> ServiceFactory<ConnectInfo<R>> for Resolver
impl<R: Host> ServiceFactory<ConnectInfo<R>> for Resolver
Source§type Response = ConnectInfo<R>
type Response = ConnectInfo<R>
Responses given by the created services.
Source§type Error = ConnectError
type Error = ConnectError
Errors produced by the created services.
Source§type Service = ResolverService
type Service = ResolverService
The kind of
Service
created by this factory.Source§type Future = Ready<Result<<Resolver as ServiceFactory<ConnectInfo<R>>>::Service, <Resolver as ServiceFactory<ConnectInfo<R>>>::InitError>>
type Future = Ready<Result<<Resolver as ServiceFactory<ConnectInfo<R>>>::Service, <Resolver as ServiceFactory<ConnectInfo<R>>>::InitError>>
The future of the
Service
instance.gSource§fn new_service(&self, _: ()) -> Self::Future
fn new_service(&self, _: ()) -> Self::Future
Create and return a new service asynchronously.
Source§impl<R: Host> ServiceFactory<ConnectInfo<R>> for TcpConnector
impl<R: Host> ServiceFactory<ConnectInfo<R>> for TcpConnector
Source§type Response = Connection<R, TcpStream>
type Response = Connection<R, TcpStream>
Responses given by the created services.
Source§type Error = ConnectError
type Error = ConnectError
Errors produced by the created services.
Source§type Service = TcpConnectorService
type Service = TcpConnectorService
The kind of
Service
created by this factory.Source§type Future = Ready<Result<<TcpConnector as ServiceFactory<ConnectInfo<R>>>::Service, <TcpConnector as ServiceFactory<ConnectInfo<R>>>::InitError>>
type Future = Ready<Result<<TcpConnector as ServiceFactory<ConnectInfo<R>>>::Service, <TcpConnector as ServiceFactory<ConnectInfo<R>>>::InitError>>
The future of the
Service
instance.gSource§fn new_service(&self, _: ()) -> Self::Future
fn new_service(&self, _: ()) -> Self::Future
Create and return a new service asynchronously.
impl<R: Eq> Eq for ConnectInfo<R>
impl<R> StructuralPartialEq for ConnectInfo<R>
Auto Trait Implementations§
impl<R> Freeze for ConnectInfo<R>where
R: Freeze,
impl<R> RefUnwindSafe for ConnectInfo<R>where
R: RefUnwindSafe,
impl<R> Send for ConnectInfo<R>where
R: Send,
impl<R> Sync for ConnectInfo<R>where
R: Sync,
impl<R> Unpin for ConnectInfo<R>where
R: Unpin,
impl<R> UnwindSafe for ConnectInfo<R>where
R: 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
Mutably borrows from an owned value. Read more