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§
Source§impl ClientRequestBuilder
impl ClientRequestBuilder
Sourcepub fn with_header<K, V>(self, key: K, value: V) -> Self
pub fn with_header<K, V>(self, key: K, value: V) -> Self
Adds (key
, value
) as an additional header to the handshake request
Sourcepub fn with_sub_protocol<P>(self, protocol: P) -> Self
pub fn with_sub_protocol<P>(self, protocol: P) -> Self
Adds protocol
to the handshake request subprotocols (Sec-WebSocket-Protocol
)
Trait Implementations§
Source§impl Clone for ClientRequestBuilder
impl Clone for ClientRequestBuilder
Source§fn clone(&self) -> ClientRequestBuilder
fn clone(&self) -> ClientRequestBuilder
Returns a copy 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 moreSource§impl Debug for ClientRequestBuilder
impl Debug for ClientRequestBuilder
Source§impl IntoClientRequest for ClientRequestBuilder
impl IntoClientRequest for ClientRequestBuilder
Source§fn into_client_request(self) -> Result<Request>
fn into_client_request(self) -> Result<Request>
Convert into a
Request
that can be used for a client connection.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)