Struct hypers::tungstenite::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 const fn new(uri: Uri) -> ClientRequestBuilder
pub const fn new(uri: Uri) -> ClientRequestBuilder
Initializes an empty request builder
sourcepub 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
sourcepub 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§
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
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)