Struct ClientRequestBuilder
pub struct ClientRequestBuilder { /* private fields */ }Expand description
Builder for a custom IntoClientRequest with options to add
custom additional headers and sub protocols.
§Example
use http::Uri;
use tungstenite::{connect, ClientRequestBuilder};
let uri: Uri = "ws://localhost:3012/socket".parse().unwrap();
let token = "my_jwt_token";
let builder = ClientRequestBuilder::new(uri)
.with_header("Authorization", format!("Bearer {token}"))
.with_sub_protocol("my_sub_protocol");
let socket = connect(builder).unwrap();Implementations§
§impl ClientRequestBuilder
impl ClientRequestBuilder
pub const fn new(uri: Uri) -> ClientRequestBuilder
pub const fn new(uri: Uri) -> ClientRequestBuilder
Initializes an empty request builder
pub fn with_header<K, V>(self, key: K, value: V) -> ClientRequestBuilder
pub fn with_header<K, V>(self, key: K, value: V) -> ClientRequestBuilder
Adds (key, value) as an additional header to the handshake request
pub fn with_sub_protocol<P>(self, protocol: P) -> ClientRequestBuilder
pub fn with_sub_protocol<P>(self, protocol: P) -> ClientRequestBuilder
Adds protocol to the handshake request subprotocols (Sec-WebSocket-Protocol)
Trait Implementations§
§impl Clone for ClientRequestBuilder
impl Clone for ClientRequestBuilder
§fn clone(&self) -> ClientRequestBuilder
fn clone(&self) -> ClientRequestBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl Debug for ClientRequestBuilder
impl Debug for ClientRequestBuilder
§impl IntoClientRequest for ClientRequestBuilder
impl IntoClientRequest for ClientRequestBuilder
Auto Trait Implementations§
impl !Freeze for ClientRequestBuilder
impl RefUnwindSafe for ClientRequestBuilder
impl Send for ClientRequestBuilder
impl Sync for ClientRequestBuilder
impl Unpin for ClientRequestBuilder
impl UnwindSafe for ClientRequestBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more