From c0482e09c3362fa7ff00a5af04938595bbae4706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 21 Nov 2022 16:23:47 +0100 Subject: [PATCH] Revert "fix(ext/websocket): make try_send ops infallible (#16454)" (#16743) This reverts commit d76014192dbfd134794a6129e73f38645d7e6314. --- ext/websocket/lib.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/ext/websocket/lib.rs b/ext/websocket/lib.rs index 984d39e9dc..704c699a76 100644 --- a/ext/websocket/lib.rs +++ b/ext/websocket/lib.rs @@ -504,12 +504,9 @@ pub fn op_ws_try_send_string( state: &mut OpState, rid: ResourceId, text: String, -) -> bool { - let resource = match state.resource_table.get::(rid) { - Ok(resource) => resource, - Err(_) => return false, - }; - resource.try_send(Message::Text(text)).is_ok() +) -> Result { + let resource = state.resource_table.get::(rid)?; + resource.try_send(Message::Text(text)) } #[op(fast)] @@ -517,12 +514,9 @@ pub fn op_ws_try_send_binary( state: &mut OpState, rid: u32, value: &[u8], -) -> bool { - let resource = match state.resource_table.get::(rid) { - Ok(resource) => resource, - Err(_) => return false, - }; - resource.try_send(Message::Binary(value.to_vec())).is_ok() +) -> Result { + let resource = state.resource_table.get::(rid)?; + resource.try_send(Message::Binary(value.to_vec())) } #[op(deferred)]