pub struct ConnectInfo<R> { /* private fields */ }
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§fn poll_ready(&self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn poll_ready(&self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
Returns
Ready
when the service is able to process requests. Read moresource§fn call(&self, req: ConnectInfo<R>) -> Self::Future
fn call(&self, req: ConnectInfo<R>) -> Self::Future
Process the request and return the response asynchronously. Read more
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§fn poll_ready(&self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn poll_ready(&self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
Returns
Ready
when the service is able to process requests. Read moresource§fn call(&self, req: ConnectInfo<R>) -> Self::Future
fn call(&self, req: ConnectInfo<R>) -> Self::Future
Process the request and return the response asynchronously. Read more
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§fn poll_ready(&self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn poll_ready(&self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
Returns
Ready
when the service is able to process requests. Read moresource§fn call(&self, req: ConnectInfo<R>) -> Self::Future
fn call(&self, req: ConnectInfo<R>) -> Self::Future
Process the request and return the response asynchronously. Read more
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