Struct tungstenite::client::ClientRequestBuilder
source · 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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)