pub struct RequestHandle {
conn: Mutex<Arc<Receiver>>,
id: AnyRequestId,
}
Expand description
A handle to an open request.
These handles are created with RpcConn::execute_with_handle
.
Note that dropping a RequestHandle does not cancel the associated request:
it will continue running, but you won’t have a way to receive updates from it.
To cancel a request, use RpcConn::cancel
.
Fields§
§conn: Mutex<Arc<Receiver>>
The underlying Receiver
that we’ll use to get updates for this request
It’s wrapped in a Mutex
to prevent concurrent calls to Receiver::wait_on_message_for
.
id: AnyRequestId
The ID of this request.
Implementations§
Source§impl RequestHandle
impl RequestHandle
Sourcepub fn id(&self) -> &AnyRequestId
pub fn id(&self) -> &AnyRequestId
Return the ID of this request, to help cancelling it.
Sourcepub fn wait(self) -> Result<Result<SuccessResponse, ErrorResponse>, ProtoError>
pub fn wait(self) -> Result<Result<SuccessResponse, ErrorResponse>, ProtoError>
Wait for success or failure, and return what happened.
(Ignores any update messages that are received.)
Note that this function will return Err(.)
only if sending the command or getting a
response failed. If the command was sent successfully, and Arti reported an error in response,
this function returns Ok(Err(.))
.
Sourcepub fn wait_with_updates(&self) -> Result<AnyResponse, ProtoError>
pub fn wait_with_updates(&self) -> Result<AnyResponse, ProtoError>
Wait for the next success, failure, or update from this handle.
Note that this function will return Err(.)
only if sending the command or getting a
response failed. If the command was sent successfully, and Arti reported an error in response,
this function returns Ok(AnyResponse::Error(.))
.
You may call this method on the same RequestHandle
from multiple threads.
If you do so, those calls will receive responses (or errors) in an unspecified order.
If this function returns Success or Error, then you shouldn’t call it again.
All future calls to this function will fail with CmdError::RequestCancelled
.
(TODO RPC: Maybe rename that error.)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RequestHandle
impl RefUnwindSafe for RequestHandle
impl Send for RequestHandle
impl Sync for RequestHandle
impl Unpin for RequestHandle
impl UnwindSafe for RequestHandle
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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