Destination

Struct Destination 

Source
pub struct Destination { /* private fields */ }
Expand description

A set of properties to describe where and how to try to connect.

This type is passed an argument for the Connect trait.

Implementations§

Source§

impl Destination

Source

pub fn try_from_uri(uri: Uri) -> Result<Destination, Error>

Try to convert a Uri into a Destination

§Error

Returns an error if the uri contains no authority or no scheme.

Source

pub fn scheme(&self) -> &str

Get the protocol scheme.

Source

pub fn host(&self) -> &str

Get the hostname.

Source

pub fn port(&self) -> Option<u16>

Get the port, if specified.

Source

pub fn set_scheme(&mut self, scheme: &str) -> Result<(), Error>

Update the scheme of this destination.

§Example
// let mut dst = some_destination...
// Change from "http://"...
assert_eq!(dst.scheme(), "http");

// to "ws://"...
dst.set_scheme("ws");
assert_eq!(dst.scheme(), "ws");
§Error

Returns an error if the string is not a valid scheme.

Source

pub fn set_host(&mut self, host: &str) -> Result<(), Error>

Update the host of this destination.

§Example
// let mut dst = some_destination...
// Change from "hyper.rs"...
assert_eq!(dst.host(), "hyper.rs");

// to "some.proxy"...
dst.set_host("some.proxy");
assert_eq!(dst.host(), "some.proxy");
§Error

Returns an error if the string is not a valid hostname.

Source

pub fn set_port<P>(&mut self, port: P)
where P: Into<Option<u16>>,

Update the port of this destination.

§Example
// let mut dst = some_destination...
// Change from "None"...
assert_eq!(dst.port(), None);

// to "4321"...
dst.set_port(4321);
assert_eq!(dst.port(), Some(4321));

// Or remove the port...
dst.set_port(None);
assert_eq!(dst.port(), None);

Trait Implementations§

Source§

impl Clone for Destination

Source§

fn clone(&self) -> Destination

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Destination

Source§

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

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

impl<C> Service<Destination> for Connector<C>
where C: Connect,

Source§

type Response = <C as Connect>::Transport

Responses given by the service.
Source§

type Error = <C as Connect>::Error

Errors produced by the service.
Source§

type Future = ConnectorFuture<C>

The future response value.
Source§

fn poll_ready(&mut self) -> Poll<(), Self::Error>

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

fn call(&mut self, target: Destination) -> Self::Future

Process the request and return the response asynchronously. Read more
Source§

impl TryFrom<Uri> for Destination

Available on try_from only.
Source§

type Error = Error

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

fn try_from( uri: Uri, ) -> Result<Destination, <Destination as TryFrom<Uri>>::Error>

Performs the conversion.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.