pub struct Service<T>where
T: ClientImpl,{ /* private fields */ }client only.Expand description
The service which drives a connection.
This is constructed through connect() and has to be driven by calling
Service::run.
Implementations§
Source§impl<T> Service<T>where
T: ClientImpl,
impl<T> Service<T>where
T: ClientImpl,
Sourcepub fn handle(&self) -> &Handle
pub fn handle(&self) -> &Handle
Get a handle to the service.
The returned handle can be cloned and moved freely between tasks.
Sourcepub async fn run(&mut self) -> Result<(), Error>
pub async fn run(&mut self) -> Result<(), Error>
Run the service.
This drives the underlying connection and must be called for any requests to be processed. It is typically spawned onto a task of its own.
Unless disabled through ServiceBuilder::reconnect, a connection
which is lost is re-established with an exponential backoff. Any
requests which were in flight at that point are failed.
This returns once Handle::close has been called, or the connection
has been lost while reconnecting is disabled.
§Errors
Errors if the server states another application version, see
ServiceBuilder::app_version. The service has then stopped for good,
and calling this again returns immediately.
Errors right away, without connecting, if a header was passed to
ServiceBuilder::header which cannot be sent.
Sourcepub async fn try_connect(&mut self) -> Result<(), Error>
pub async fn try_connect(&mut self) -> Result<(), Error>
Establish the connection now, returning a failure to the caller instead of scheduling a reconnect.
This lets a caller fail fast when there is nothing to connect to, such
as a refused connection or a missing unix socket, rather than leaving
Service::run to retry with a backoff. On success the established
connection is the one Service::run goes on to drive. If a connection
is already established this does nothing.
The error is not reported through ServiceBuilder::on_error. The
underlying transport error is available through
core::error::Error::source on the returned error.
Errors without connecting if a header was passed to
ServiceBuilder::header which cannot be sent, see
Error::is_invalid_header.
Trait Implementations§
Source§impl<T> Debug for Service<T>where
T: ClientImpl,
impl<T> Debug for Service<T>where
T: ClientImpl,
Source§impl<T> Drop for Service<T>where
T: ClientImpl,
impl<T> Drop for Service<T>where
T: ClientImpl,
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Service<T>
impl<T> !UnwindSafe for Service<T>
impl<T> Freeze for Service<T>where
Option<<T as ClientImpl>::Connector>: Freeze,
<T as ClientImpl>::Headers: Freeze,
Option<<T as ClientImpl>::Socket>: Freeze,
impl<T> Send for Service<T>where
Option<<T as ClientImpl>::Connector>: Send,
<T as ClientImpl>::Headers: Send,
Option<<T as ClientImpl>::Socket>: Send,
impl<T> Sync for Service<T>where
Option<<T as ClientImpl>::Connector>: Sync,
<T as ClientImpl>::Headers: Sync,
Option<<T as ClientImpl>::Socket>: Sync,
impl<T> Unpin for Service<T>where
Option<<T as ClientImpl>::Connector>: Unpin,
<T as ClientImpl>::Headers: Unpin,
Option<<T as ClientImpl>::Socket>: Unpin,
impl<T> UnsafeUnpin for Service<T>where
Option<<T as ClientImpl>::Connector>: UnsafeUnpin,
<T as ClientImpl>::Headers: UnsafeUnpin,
Option<<T as ClientImpl>::Socket>: UnsafeUnpin,
Blanket Implementations§
impl<Token, Builder, How> AllPropsFor<Builder, How> for Tokenwhere
Builder: Buildable<Token>,
<Builder as Buildable<Token>>::WrappedToken: HasAllProps<<Builder as Buildable<Token>>::Output, How>,
impl<Token, Builder, How> AllPropsFor<Builder, How> for Tokenwhere
Builder: Buildable<Token>,
<Builder as Buildable<Token>>::WrappedToken: HasAllProps<<Builder as Buildable<Token>>::Output, How>,
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
impl<T> HasAllProps<(), T> for T
impl<T> HasAllProps<(), T> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
self to a value of a Properties struct.Source§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
self to a value of a Properties struct.Source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
self to a value of a Properties struct.Source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
self to a value of a Properties struct.