pub struct RpcResponseHandler {
engine: Arc<WshRpcEngine>,
req_id: String,
source: String,
canceled: AtomicBool,
done: AtomicBool,
}Expand description
Allows an RPC handler to send responses back to the caller.
Matches Go’s RpcResponseHandler.
Fields§
§engine: Arc<WshRpcEngine>§req_id: String§source: String§canceled: AtomicBool§done: AtomicBoolImplementations§
Source§impl RpcResponseHandler
impl RpcResponseHandler
Sourcepub fn send_response(&self, data: Option<Value>, done: bool)
pub fn send_response(&self, data: Option<Value>, done: bool)
Send a single response (or streaming chunk).
Set done to true for the final response.
Sourcepub fn send_error(&self, err: &str)
pub fn send_error(&self, err: &str)
Send an error response.
Sourcepub fn is_canceled(&self) -> bool
pub fn is_canceled(&self) -> bool
Check if the request has been canceled.
Sourcepub fn get_source(&self) -> &str
pub fn get_source(&self) -> &str
Get the source route ID of the request.
Auto Trait Implementations§
impl !Freeze for RpcResponseHandler
impl RefUnwindSafe for RpcResponseHandler
impl Send for RpcResponseHandler
impl Sync for RpcResponseHandler
impl Unpin for RpcResponseHandler
impl UnwindSafe for RpcResponseHandler
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
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.