1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-28 09:42:40 +01:00

better ergonomics for ws client

This commit is contained in:
Nikolay Kim 2018-02-24 07:36:50 +03:00
parent 3b22b1b168
commit fd31eb74c5

View File

@ -128,7 +128,7 @@ impl WsClient {
} }
/// Set supported websocket protocols /// Set supported websocket protocols
pub fn protocols<U, V>(&mut self, protos: U) -> &mut Self pub fn protocols<U, V>(mut self, protos: U) -> Self
where U: IntoIterator<Item=V> + 'static, where U: IntoIterator<Item=V> + 'static,
V: AsRef<str> V: AsRef<str>
{ {
@ -140,13 +140,13 @@ impl WsClient {
} }
/// Set cookie for handshake request /// Set cookie for handshake request
pub fn cookie<'c>(&mut self, cookie: Cookie<'c>) -> &mut Self { pub fn cookie<'c>(mut self, cookie: Cookie<'c>) -> Self {
self.request.cookie(cookie); self.request.cookie(cookie);
self self
} }
/// Set request Origin /// Set request Origin
pub fn origin<V>(&mut self, origin: V) -> &mut Self pub fn origin<V>(mut self, origin: V) -> Self
where HeaderValue: HttpTryFrom<V> where HeaderValue: HttpTryFrom<V>
{ {
match HeaderValue::try_from(origin) { match HeaderValue::try_from(origin) {
@ -157,7 +157,7 @@ impl WsClient {
} }
/// Set request header /// Set request header
pub fn header<K, V>(&mut self, key: K, value: V) -> &mut Self pub fn header<K, V>(mut self, key: K, value: V) -> Self
where HeaderName: HttpTryFrom<K>, HeaderValue: HttpTryFrom<V> where HeaderName: HttpTryFrom<K>, HeaderValue: HttpTryFrom<V>
{ {
self.request.header(key, value); self.request.header(key, value);