pub struct RunningService<R, S>where
R: ServiceRole,
S: Service<R>,{ /* private fields */ }Implementations§
Source§impl<R, S> RunningService<R, S>where
R: ServiceRole,
S: Service<R>,
impl<R, S> RunningService<R, S>where
R: ServiceRole,
S: Service<R>,
pub fn peer(&self) -> &Peer<R>
pub fn service(&self) -> &S
pub fn cancellation_token(&self) -> RunningServiceCancellationToken
Sourcepub async fn waiting(self) -> Result<QuitReason, JoinError>
pub async fn waiting(self) -> Result<QuitReason, JoinError>
Wait for the service to complete.
This will block until the service loop terminates (either due to cancellation, transport closure, or an error).
Sourcepub async fn close(&mut self) -> Result<QuitReason, JoinError>
pub async fn close(&mut self) -> Result<QuitReason, JoinError>
Gracefully close the connection and wait for cleanup to complete.
This method cancels the service, waits for the background task to finish
(which includes calling transport.close()), and ensures all cleanup
operations complete before returning.
Unlike cancel, this method takes &mut self and can be
called without consuming the RunningService. After calling this method,
the service is considered closed and subsequent operations will fail.
§Example
let mut client = ().serve(transport).await?;
// ... use the client ...
client.close().await?;Sourcepub async fn close_with_timeout(
&mut self,
timeout: Duration,
) -> Result<Option<QuitReason>, JoinError>
pub async fn close_with_timeout( &mut self, timeout: Duration, ) -> Result<Option<QuitReason>, JoinError>
Gracefully close the connection with a timeout.
Similar to close, but returns after the specified timeout
if the cleanup doesn’t complete in time. This is useful for ensuring
a bounded shutdown time.
Returns Ok(Some(reason)) if shutdown completed within the timeout,
Ok(None) if the timeout was reached, or Err if there was a join error.