pub fn add_protocols<I, S>(mut self, protocols: I) -> Self
	where
		I: IntoIterator<Item = S>,
		S: Into<String>,
	{
		let protocols: Vec<String> = protocols.into_iter().map(Into::into).collect();

		self.headers.insert(SEC_WEBSOCKET_PROTOCOL, WebSocketProtocol(protocols).into());
		self
	}
/// Adds a user-defined protocols to the handshake.
/// This can take many kinds of iterators.
///
/// ```rust
/// # extern crate http;
/// # extern crate websocket;
/// # use http::header::SEC_WEBSOCKET_PROTOCOL;
/// # use websocket::ClientBuilder;
/// # use websocket::header::WebSocketProtocol;
/// fn main() {
/// let builder = ClientBuilder::new("wss://my-twitch-clone.rs").unwrap()
///     .add_protocols(vec!["pubsub", "sub.events"]);
///
/// let protos = &builder.get_header(SEC_WEBSOCKET_PROTOCOL).unwrap()
///     .to_str().unwrap()
///     .parse::<WebSocketProtocol>().unwrap().0;
/// assert!(protos.contains(&"pubsub".to_string()));
/// assert!(protos.contains(&"sub.events".to_string()));
/// }
/// ```
Adds a user-defined protocols to the handshake.
This can take many kinds of iterators.


Adds a user - defined protocols to the handshake . This can take many kinds of iterators .
pub fn add_protocols<I, S>(mut self, protocols: I) -> Self
	where
		I: IntoIterator<Item = S>,
		S: Into<String>,
	{
		let protocols: Vec<String> = protocols.into_iter().map(Into::into).collect();
		self.headers.insert(SEC_WEBSOCKET_PROTOCOL, WebSocketProtocol(protocols).into());
		self
	}
pub fn add_protocols < I , S > ( mut self , protocols : I ) -> Self where I : IntoIterator < Item = S > , S : Into < String > , { let protocols : Vec < String > = protocols . into_iter ( ) . map ( Into :: into ) . collect ( ) ; self . headers . insert ( SEC_WEBSOCKET_PROTOCOL , WebSocketProtocol ( protocols ) . into ( ) ) ; self }
Adds a user-defined protocols to the handshake.
Adds a user - defined protocols to the handshake .
mut self
protocols
I
mut self
protocols
I
extern crate http;
None
extern crate websocket;
None
use http::header::sec_websocket_protocol;
None
use websocket::clientbuilder;
None
use websocket::header::websocketprotocol;
fn main() {
let builder = ClientBuilder::new("wss://my-twitch-clone.rs").unwrap()
.add_protocols(vec!["pubsub", "sub.events"]).

let protos = &builder.get_header(SEC_WEBSOCKET_PROTOCOL).unwrap()
.to_str().unwrap()
.parse::().unwrap().0;
assert!(protos.contains(&"pubsub".to_string()));
assert!(protos.contains(&"sub.events".to_string()));
}
```
fn main () { let builder = ClientBuilder :: new ( " wss : // my - twitch - clone . rs " ) . unwrap () . add_protocols ( vec! [ " pubsub " " sub . events " ] ) . let protos = &builder . get_header ( SEC_WEBSOCKET_PROTOCOL ) . unwrap () . to_str () . unwrap () . parse :: () . unwrap () . 0 ; assert! ( protos . contains ( & " pubsub " . to_string () )) ; assert! ( protos . contains ( & " sub . events " . to_string () )) ; } ` ` `