Struct ClientRequestBuilder

struct ClientRequestBuilder { ... }

Builder for a custom IntoClientRequest with options to add custom additional headers and sub protocols.

Example

# use crate::*;
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

const fn new(uri: Uri) -> Self

Initializes an empty request builder

fn with_header<K, V>(self: Self, key: K, value: V) -> Self
where
    K: Into<String>,
    V: Into<String>

Adds (key, value) as an additional header to the handshake request

fn with_sub_protocol<P>(self: Self, protocol: P) -> Self
where
    P: Into<String>

Adds protocol to the handshake request subprotocols (Sec-WebSocket-Protocol)

impl Clone for ClientRequestBuilder

fn clone(self: &Self) -> ClientRequestBuilder

impl Debug for ClientRequestBuilder

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Freeze for ClientRequestBuilder

impl IntoClientRequest for ClientRequestBuilder

fn into_client_request(self: Self) -> Result<Request>

impl RefUnwindSafe for ClientRequestBuilder

impl Send for ClientRequestBuilder

impl Sync for ClientRequestBuilder

impl Unpin for ClientRequestBuilder

impl UnsafeUnpin for ClientRequestBuilder

impl UnwindSafe for ClientRequestBuilder

impl<T> Any for ClientRequestBuilder

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for ClientRequestBuilder

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for ClientRequestBuilder

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for ClientRequestBuilder

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for ClientRequestBuilder

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Same for ClientRequestBuilder

impl<T> ToOwned for ClientRequestBuilder

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for ClientRequestBuilder

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for ClientRequestBuilder

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for ClientRequestBuilder

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>

impl<V, T> VZip for ClientRequestBuilder

fn vzip(self: Self) -> V