From 529f17c097c79b87c1d241514becd72c73f93fef Mon Sep 17 00:00:00 2001 From: Marc Brinkmann Date: Tue, 12 Mar 2024 14:02:03 +0100 Subject: [PATCH] Make `send_custom_error` available on the server as well --- src/rpc.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/rpc.rs b/src/rpc.rs index 34f58d4..0e9653f 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -475,6 +475,16 @@ where (deadline, timed_out) } + + /// Injects a custom error. + /// + /// Similar to [`JulietRpcClient::send_custom_error`]. This function is available for + /// convenience to allow the server to terminate the connection with an error without having + /// keep a client around. + #[inline] + pub fn send_custom_error(&self, channel: ChannelId, id: Id, error: Bytes) -> bool { + self.handle.enqueue_error(channel, id, error).is_ok() + } } impl Drop for JulietRpcServer {