summaryrefslogtreecommitdiff
path: root/op_crates/websocket/lib.rs
diff options
context:
space:
mode:
authorcrowlKats <13135287+crowlKats@users.noreply.github.com>2021-04-30 17:03:50 +0200
committerGitHub <noreply@github.com>2021-04-30 11:03:50 -0400
commit6804b2f8891822f213f2e2a417f1659d2df77e02 (patch)
treee14bd552006c9f7c234432417f7806bb42e1251c /op_crates/websocket/lib.rs
parentfc9c7de94b08049dd04c4ca6016586cdac0dd2ac (diff)
refactor(websocket): use ZeroCopyBuf to return binary data (#10446)
Diffstat (limited to 'op_crates/websocket/lib.rs')
-rw-r--r--op_crates/websocket/lib.rs7
1 files changed, 2 insertions, 5 deletions
diff --git a/op_crates/websocket/lib.rs b/op_crates/websocket/lib.rs
index b81b1701d..acf823775 100644
--- a/op_crates/websocket/lib.rs
+++ b/op_crates/websocket/lib.rs
@@ -289,7 +289,7 @@ pub async fn op_ws_close(
#[serde(tag = "kind", content = "value", rename_all = "camelCase")]
pub enum NextEventResponse {
String(String),
- Binary(Vec<u8>),
+ Binary(ZeroCopyBuf),
Close { code: u16, reason: String },
Ping,
Pong,
@@ -313,10 +313,7 @@ pub async fn op_ws_next_event(
let val = rx.next().or_cancel(cancel).await?;
let res = match val {
Some(Ok(Message::Text(text))) => NextEventResponse::String(text),
- Some(Ok(Message::Binary(data))) => {
- // TODO(ry): don't use json to send binary data.
- NextEventResponse::Binary(data)
- }
+ Some(Ok(Message::Binary(data))) => NextEventResponse::Binary(data.into()),
Some(Ok(Message::Close(Some(frame)))) => NextEventResponse::Close {
code: frame.code.into(),
reason: frame.reason.to_string(),