1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
Index: warp/src/filters/ws.rs
===================================================================
--- warp.orig/src/filters/ws.rs
+++ warp/src/filters/ws.rs
@@ -6,20 +6,18 @@ use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
-use bytes::Bytes;
+use super::header;
+use crate::filter::{filter_fn_one, Filter, One};
+use crate::reject::Rejection;
+use crate::reply::{Reply, Response};
use futures_util::{future, ready, FutureExt, Sink, Stream, TryFutureExt};
use headers::{Connection, HeaderMapExt, SecWebsocketAccept, SecWebsocketKey, Upgrade};
use hyper::upgrade::OnUpgrade;
use tokio_tungstenite::{
- tungstenite::protocol::{self, frame::Utf8Bytes, WebSocketConfig},
+ tungstenite::protocol::{self, WebSocketConfig},
WebSocketStream,
};
-use super::header;
-use crate::filter::{filter_fn_one, Filter, One};
-use crate::reject::Rejection;
-use crate::reply::{Reply, Response};
-
/// Creates a Websocket Filter.
///
/// The yielded `Ws` is used to finish the websocket upgrade.
@@ -286,23 +284,23 @@ pub struct Message {
impl Message {
/// Construct a new Text `Message`.
- pub fn text<B: Into<String>>(bytes: B) -> Message {
+ pub fn text<S: Into<String>>(s: S) -> Message {
Message {
- inner: protocol::Message::text(bytes.into()),
+ inner: protocol::Message::text(s),
}
}
/// Construct a new Binary `Message`.
- pub fn binary<B: Into<Bytes>>(bytes: B) -> Message {
+ pub fn binary<V: Into<Vec<u8>>>(v: V) -> Message {
Message {
- inner: protocol::Message::binary(bytes),
+ inner: protocol::Message::binary(v),
}
}
/// Construct a new Ping `Message`.
- pub fn ping<B: Into<Bytes>>(bytes: B) -> Message {
+ pub fn ping<V: Into<Vec<u8>>>(v: V) -> Message {
Message {
- inner: protocol::Message::Ping(bytes.into()),
+ inner: protocol::Message::Ping(v.into()),
}
}
@@ -311,9 +309,9 @@ impl Message {
/// Note that one rarely needs to manually construct a Pong message because the underlying tungstenite socket
/// automatically responds to the Ping messages it receives. Manual construction might still be useful in some cases
/// like in tests or to send unidirectional heartbeats.
- pub fn pong<B: Into<Bytes>>(bytes: B) -> Message {
+ pub fn pong<V: Into<Vec<u8>>>(v: V) -> Message {
Message {
- inner: protocol::Message::Pong(bytes.into()),
+ inner: protocol::Message::Pong(v.into()),
}
}
@@ -329,10 +327,7 @@ impl Message {
Message {
inner: protocol::Message::Close(Some(protocol::frame::CloseFrame {
code: protocol::frame::coding::CloseCode::from(code.into()),
- reason: match reason.into() {
- Cow::Borrowed(s) => Utf8Bytes::from_static(s),
- Cow::Owned(s) => s.into(),
- },
+ reason: reason.into(),
})),
}
}
@@ -392,7 +387,7 @@ impl Message {
}
/// Destructure this message into binary data.
- pub fn into_bytes(self) -> Bytes {
+ pub fn into_bytes(self) -> Vec<u8> {
self.inner.into_data()
}
}
@@ -403,7 +398,7 @@ impl fmt::Debug for Message {
}
}
-impl From<Message> for Bytes {
+impl From<Message> for Vec<u8> {
fn from(m: Message) -> Self {
m.into_bytes()
}
Index: warp/src/test.rs
===================================================================
--- warp.orig/src/test.rs
+++ warp/src/test.rs
@@ -587,7 +587,7 @@ impl WsBuilder {
impl WsClient {
/// Send a "text" websocket message to the server.
pub async fn send_text(&mut self, text: impl Into<String>) {
- self.send(crate::ws::Message::text(text.into())).await;
+ self.send(crate::ws::Message::text(text)).await;
}
/// Send a websocket message to the server.
Index: warp/Cargo.toml
===================================================================
--- warp.orig/Cargo.toml
+++ warp/Cargo.toml
@@ -162,7 +162,7 @@ features = [
]
[dependencies.tokio-tungstenite]
-version = "0.27"
+version = "0.24"
optional = true
[dependencies.tokio-util]
|