pub struct RunningService<R: ServiceRole, S: Service<R>> { /* private fields */ }client or server only.Implementations§
Source§impl<R: ServiceRole, S: Service<R>> RunningService<R, S>
impl<R: ServiceRole, S: Service<R>> RunningService<R, S>
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.
Methods from Deref<Target = Peer<R>>§
pub async fn send_notification( &self, notification: R::Not, ) -> Result<(), ServiceError>
pub async fn send_request( &self, request: R::Req, ) -> Result<R::PeerResp, ServiceError>
pub async fn send_cancellable_request( &self, request: R::Req, options: PeerRequestOptions, ) -> Result<RequestHandle<R>, ServiceError>
pub async fn send_request_with_option( &self, request: R::Req, options: PeerRequestOptions, ) -> Result<RequestHandle<R>, ServiceError>
pub fn peer_info(&self) -> Option<&R::PeerInfo>
pub fn set_peer_info(&self, info: R::PeerInfo)
pub fn is_transport_closed(&self) -> bool
Trait Implementations§
Source§impl<R: Debug + ServiceRole, S: Debug + Service<R>> Debug for RunningService<R, S>
impl<R: Debug + ServiceRole, S: Debug + Service<R>> Debug for RunningService<R, S>
Source§impl<R: ServiceRole, S: Service<R>> Deref for RunningService<R, S>
impl<R: ServiceRole, S: Service<R>> Deref for RunningService<R, S>
Source§impl<R: ServiceRole, S: Service<R>> Drop for RunningService<R, S>
impl<R: ServiceRole, S: Service<R>> Drop for RunningService<R, S>
Auto Trait Implementations§
impl<R, S> Freeze for RunningService<R, S>
impl<R, S> !RefUnwindSafe for RunningService<R, S>
impl<R, S> Send for RunningService<R, S>
impl<R, S> Sync for RunningService<R, S>
impl<R, S> Unpin for RunningService<R, S>
impl<R, S> !UnwindSafe for RunningService<R, S>
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
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read moreSource§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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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