actix_tls::connect

Struct ConnectInfo

source
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>

source

pub fn new(request: R) -> ConnectInfo<R>

Constructs new connection info using a request.

source

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.

source

pub fn set_port(self, port: u16) -> Self

Set connection port.

If request provided a port, this will override it.

source

pub fn set_addr(self, addr: impl Into<Option<SocketAddr>>) -> Self

Set connection socket address.

source

pub fn set_addrs<I>(self, addrs: I) -> Self
where I: IntoIterator<Item = SocketAddr>,

Set list of addresses.

source

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.

source

pub fn request(&self) -> &R

Returns a reference to the connection request.

source

pub fn hostname(&self) -> &str

Returns request hostname.

source

pub fn port(&self) -> u16

Returns request port.

source

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);
source

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>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<R: Host> Display for ConnectInfo<R>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<R: Host> From<R> for ConnectInfo<R>

source§

fn from(addr: R) -> Self

Converts to this type from the input type.
source§

impl<R: Hash> Hash for ConnectInfo<R>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.6.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<R: PartialEq> PartialEq for ConnectInfo<R>

source§

fn eq(&self, other: &ConnectInfo<R>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.6.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<R: Host> Service<ConnectInfo<R>> for ConnectorService

source§

type Response = Connection<R, TcpStream>

Responses given by the service.
source§

type Error = ConnectError

Errors produced by the service when polling readiness or executing call.
source§

type Future = ConnectServiceResponse<R>

The future response value.
source§

fn poll_ready(&self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>>

Returns Ready when the service is able to process requests. Read more
source§

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

source§

type Response = ConnectInfo<R>

Responses given by the service.
source§

type Error = ConnectError

Errors produced by the service when polling readiness or executing call.
source§

type Future = ResolverFut<R>

The future response value.
source§

fn poll_ready(&self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>>

Returns Ready when the service is able to process requests. Read more
source§

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

source§

type Response = Connection<R, TcpStream>

Responses given by the service.
source§

type Error = ConnectError

Errors produced by the service when polling readiness or executing call.
source§

type Future = TcpConnectorFut<R>

The future response value.
source§

fn poll_ready(&self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>>

Returns Ready when the service is able to process requests. Read more
source§

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

source§

type Response = Connection<R, TcpStream>

Responses given by the created services.
source§

type Error = ConnectError

Errors produced by the created services.
source§

type Config = ()

Service factory configuration.
source§

type Service = ConnectorService

The kind of Service created by this factory.
source§

type InitError = ()

Errors potentially raised while building a service.
source§

type Future = Ready<Result<<Connector as ServiceFactory<ConnectInfo<R>>>::Service, <Connector as ServiceFactory<ConnectInfo<R>>>::InitError>>

The future of the Service instance.g
source§

fn new_service(&self, _: ()) -> Self::Future

Create and return a new service asynchronously.
source§

impl<R: Host> ServiceFactory<ConnectInfo<R>> for Resolver

source§

type Response = ConnectInfo<R>

Responses given by the created services.
source§

type Error = ConnectError

Errors produced by the created services.
source§

type Config = ()

Service factory configuration.
source§

type Service = ResolverService

The kind of Service created by this factory.
source§

type InitError = ()

Errors potentially raised while building a service.
source§

type Future = Ready<Result<<Resolver as ServiceFactory<ConnectInfo<R>>>::Service, <Resolver as ServiceFactory<ConnectInfo<R>>>::InitError>>

The future of the Service instance.g
source§

fn new_service(&self, _: ()) -> Self::Future

Create and return a new service asynchronously.
source§

impl<R: Host> ServiceFactory<ConnectInfo<R>> for TcpConnector

source§

type Response = Connection<R, TcpStream>

Responses given by the created services.
source§

type Error = ConnectError

Errors produced by the created services.
source§

type Config = ()

Service factory configuration.
source§

type Service = TcpConnectorService

The kind of Service created by this factory.
source§

type InitError = ()

Errors potentially raised while building a service.
source§

type Future = Ready<Result<<TcpConnector as ServiceFactory<ConnectInfo<R>>>::Service, <TcpConnector as ServiceFactory<ConnectInfo<R>>>::InitError>>

The future of the Service instance.g
source§

fn new_service(&self, _: ()) -> Self::Future

Create and return a new service asynchronously.
source§

impl<R: Eq> Eq for ConnectInfo<R>

source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more