Struct WebSocketRequestBuilder
pub struct WebSocketRequestBuilder<B> { /* private fields */ }
Expand description
Builder that can be used by clients to initiate the WebSocket handshake.
Implementations§
§impl WebSocketRequestBuilder<Builder>
impl WebSocketRequestBuilder<Builder>
pub fn new<T>(uri: T) -> WebSocketRequestBuilder<Builder>
pub fn new<T>(uri: T) -> WebSocketRequestBuilder<Builder>
Create a new http/1.1
WebSocket Request
builder.
pub fn new_h2<T>(uri: T) -> WebSocketRequestBuilder<Builder>
pub fn new_h2<T>(uri: T) -> WebSocketRequestBuilder<Builder>
Create a new h2
WebSocket Request
builder.
pub fn with_header<K, V>(
self,
name: K,
value: V,
) -> WebSocketRequestBuilder<Builder>where
K: TryInto<HeaderName>,
<K as TryInto<HeaderName>>::Error: Into<Error>,
V: TryInto<HeaderValue>,
<V as TryInto<HeaderValue>>::Error: Into<Error>,
pub fn with_header<K, V>(
self,
name: K,
value: V,
) -> WebSocketRequestBuilder<Builder>where
K: TryInto<HeaderName>,
<K as TryInto<HeaderName>>::Error: Into<Error>,
V: TryInto<HeaderValue>,
<V as TryInto<HeaderValue>>::Error: Into<Error>,
Set a custom http header
pub fn with_typed_header<H>(self, header: H) -> WebSocketRequestBuilder<Builder>where
H: HeaderEncode,
pub fn with_typed_header<H>(self, header: H) -> WebSocketRequestBuilder<Builder>where
H: HeaderEncode,
Set a custom typed http header
pub fn build_handshake(self) -> Result<HandshakeRequest, OpaqueError>
pub fn build_handshake(self) -> Result<HandshakeRequest, OpaqueError>
Build the handshake data to be used to initiate the WebSocket handshake using an http client.
§impl<'a, S, Body> WebSocketRequestBuilder<WithService<'a, S, Body>>
impl<'a, S, Body> WebSocketRequestBuilder<WithService<'a, S, Body>>
pub fn new_with_service<T>(
service: &'a S,
uri: T,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>where
T: IntoUrl,
pub fn new_with_service<T>(
service: &'a S,
uri: T,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>where
T: IntoUrl,
Create a new http/1.1
WebSocket Request
builder.
pub fn new_h2_with_service<T>(
service: &'a S,
uri: T,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>where
T: IntoUrl,
pub fn new_h2_with_service<T>(
service: &'a S,
uri: T,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>where
T: IntoUrl,
Create a new h2
WebSocket Request
builder.
pub fn new_with_service_and_request<RequestBody>(
service: &'a S,
request: Request<RequestBody>,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>
pub fn new_with_service_and_request<RequestBody>( service: &'a S, request: Request<RequestBody>, ) -> WebSocketRequestBuilder<WithService<'a, S, Body>>
pub fn with_header<K, V>(
self,
name: K,
value: V,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>where
K: IntoHeaderName,
V: IntoHeaderValue,
pub fn with_header<K, V>(
self,
name: K,
value: V,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>where
K: IntoHeaderName,
V: IntoHeaderValue,
Set a custom http header
pub fn with_header_overwrite<K, V>(
self,
name: K,
value: V,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>where
K: IntoHeaderName,
V: IntoHeaderValue,
pub fn with_header_overwrite<K, V>(
self,
name: K,
value: V,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>where
K: IntoHeaderName,
V: IntoHeaderValue,
Overwrite a custom http header
pub fn with_typed_header<H>(
self,
header: H,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>where
H: HeaderEncode,
pub fn with_typed_header<H>(
self,
header: H,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>where
H: HeaderEncode,
Set a custom typed http header
pub fn with_typed_header_overwrite<H>(
self,
header: H,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>where
H: HeaderEncode,
pub fn with_typed_header_overwrite<H>(
self,
header: H,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>where
H: HeaderEncode,
Overwrite a custom typed http header
pub fn with_per_message_deflate(
self,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>
pub fn with_per_message_deflate( self, ) -> WebSocketRequestBuilder<WithService<'a, S, Body>>
Set/add deflate ext and also apply it to the WebSocketConfig
,
using the default crate::protocol::PerMessageDeflateConfig
.
pub fn set_per_message_deflate(
&mut self,
) -> &mut WebSocketRequestBuilder<WithService<'a, S, Body>>
pub fn set_per_message_deflate( &mut self, ) -> &mut WebSocketRequestBuilder<WithService<'a, S, Body>>
Set/add deflate ext and also apply it to the WebSocketConfig
,
using the default crate::protocol::PerMessageDeflateConfig
.
pub fn with_per_message_deflate_overwrite_extensions(
self,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>
pub fn with_per_message_deflate_overwrite_extensions( self, ) -> WebSocketRequestBuilder<WithService<'a, S, Body>>
Set/add deflate ext and also apply it to the WebSocketConfig
,
using the default crate::protocol::PerMessageDeflateConfig
.
Overwrites existing extensions if already existed.
pub fn set_per_message_deflate_overwrite_extensions(
&mut self,
) -> &mut WebSocketRequestBuilder<WithService<'a, S, Body>>
pub fn set_per_message_deflate_overwrite_extensions( &mut self, ) -> &mut WebSocketRequestBuilder<WithService<'a, S, Body>>
Set/add deflate ext and also apply it to the WebSocketConfig
,
using the default crate::protocol::PerMessageDeflateConfig
.
Overwrites existing extensions if already existed.
pub fn with_per_message_deflate_with_config(
self,
config: impl Into<PerMessageDeflateConfig>,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>
pub fn with_per_message_deflate_with_config( self, config: impl Into<PerMessageDeflateConfig>, ) -> WebSocketRequestBuilder<WithService<'a, S, Body>>
Set/add deflate ext and also apply it to the WebSocketConfig
,
using the default crate::protocol::PerMessageDeflateConfig
.
pub fn set_per_message_deflate_with_config(
&mut self,
config: impl Into<PerMessageDeflateConfig>,
) -> &mut WebSocketRequestBuilder<WithService<'a, S, Body>>
pub fn set_per_message_deflate_with_config( &mut self, config: impl Into<PerMessageDeflateConfig>, ) -> &mut WebSocketRequestBuilder<WithService<'a, S, Body>>
Set/add deflate ext and also apply it to the WebSocketConfig
,
using the default crate::protocol::PerMessageDeflateConfig
.
pub fn with_per_message_deflate_with_config_overwrite_extensions(
self,
config: impl Into<PerMessageDeflateConfig>,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>
pub fn with_per_message_deflate_with_config_overwrite_extensions( self, config: impl Into<PerMessageDeflateConfig>, ) -> WebSocketRequestBuilder<WithService<'a, S, Body>>
Set/add deflate ext and also apply it to the WebSocketConfig
,
using the default crate::protocol::PerMessageDeflateConfig
.
Overwrites existing extensions if already existed.
pub fn set_per_message_deflate_with_config_overwrite_extensions(
&mut self,
config: impl Into<PerMessageDeflateConfig>,
) -> &mut WebSocketRequestBuilder<WithService<'a, S, Body>>
pub fn set_per_message_deflate_with_config_overwrite_extensions( &mut self, config: impl Into<PerMessageDeflateConfig>, ) -> &mut WebSocketRequestBuilder<WithService<'a, S, Body>>
Set/add deflate ext and also apply it to the WebSocketConfig
,
using the default crate::protocol::PerMessageDeflateConfig
.
Overwrites existing extensions if already existed.
pub fn maybe_with_config(
self,
cfg: Option<WebSocketConfig>,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>
pub fn maybe_with_config( self, cfg: Option<WebSocketConfig>, ) -> WebSocketRequestBuilder<WithService<'a, S, Body>>
Set the WebSocketConfig
, overwriting the previous config if already set.
pub fn maybe_set_config(
&mut self,
cfg: Option<WebSocketConfig>,
) -> &mut WebSocketRequestBuilder<WithService<'a, S, Body>>
pub fn maybe_set_config( &mut self, cfg: Option<WebSocketConfig>, ) -> &mut WebSocketRequestBuilder<WithService<'a, S, Body>>
Set the WebSocketConfig
, overwriting the previous config if already set.
pub fn with_config(
self,
cfg: WebSocketConfig,
) -> WebSocketRequestBuilder<WithService<'a, S, Body>>
pub fn with_config( self, cfg: WebSocketConfig, ) -> WebSocketRequestBuilder<WithService<'a, S, Body>>
Set the WebSocketConfig
, overwriting the previous config if already set.
pub fn set_config(
&mut self,
cfg: WebSocketConfig,
) -> &mut WebSocketRequestBuilder<WithService<'a, S, Body>>
pub fn set_config( &mut self, cfg: WebSocketConfig, ) -> &mut WebSocketRequestBuilder<WithService<'a, S, Body>>
Set the WebSocketConfig
, overwriting the previous config if already set.
pub fn without_config(self) -> WebSocketRequestBuilder<WithService<'a, S, Body>>
pub fn without_config(self) -> WebSocketRequestBuilder<WithService<'a, S, Body>>
Set the WebSocketConfig
, overwriting the previous config if already set.
pub fn unset_config(
&mut self,
) -> &mut WebSocketRequestBuilder<WithService<'a, S, Body>>
pub fn unset_config( &mut self, ) -> &mut WebSocketRequestBuilder<WithService<'a, S, Body>>
Set the WebSocketConfig
, overwriting the previous config if already set.
pub async fn initiate_handshake(
self,
ctx: Context,
) -> Result<NegotiatedHandshakeRequest<Body>, HandshakeError>
pub async fn initiate_handshake( self, ctx: Context, ) -> Result<NegotiatedHandshakeRequest<Body>, HandshakeError>
Initiate the handshake by preparing the http request, sending it and receiving the http response.
This consumes this WebSocketRequestBuilder
. Fulfill
the handshake by calling NegotiatedHandshakeRequest::complete
.
In most cases you have however no need for this intermediate result,
and are better of calling Self::handshake
directly. Only in cases
such as MITM proxies or edge-case purposes you might require access
to NegotiatedHandshakeRequest
.
pub async fn handshake(
self,
ctx: Context,
) -> Result<ClientWebSocket, HandshakeError>
pub async fn handshake( self, ctx: Context, ) -> Result<ClientWebSocket, HandshakeError>
Establish a client [WebSocket
], consuming this WebSocketRequestBuilder
,
by doing the http-handshake, including validation and returning the socket if all is good.
§impl<B> WebSocketRequestBuilder<B>
impl<B> WebSocketRequestBuilder<B>
pub fn maybe_with_protocols(
self,
protocols: Option<SecWebSocketProtocol>,
) -> WebSocketRequestBuilder<B>
pub fn maybe_with_protocols( self, protocols: Option<SecWebSocketProtocol>, ) -> WebSocketRequestBuilder<B>
Define the WebSocket protocols to be used.
pub fn maybe_set_protocols(
&mut self,
protocols: Option<SecWebSocketProtocol>,
) -> &mut WebSocketRequestBuilder<B>
pub fn maybe_set_protocols( &mut self, protocols: Option<SecWebSocketProtocol>, ) -> &mut WebSocketRequestBuilder<B>
Define the WebSocket protocols to be used.
pub fn with_protocols(
self,
protocols: SecWebSocketProtocol,
) -> WebSocketRequestBuilder<B>
pub fn with_protocols( self, protocols: SecWebSocketProtocol, ) -> WebSocketRequestBuilder<B>
Define the WebSocket protocols to be used.
pub fn set_protocols(
&mut self,
protocols: SecWebSocketProtocol,
) -> &mut WebSocketRequestBuilder<B>
pub fn set_protocols( &mut self, protocols: SecWebSocketProtocol, ) -> &mut WebSocketRequestBuilder<B>
Define the WebSocket protocols to be used.
pub fn without_protocols(self) -> WebSocketRequestBuilder<B>
pub fn without_protocols(self) -> WebSocketRequestBuilder<B>
Define the WebSocket protocols to be used.
pub fn unset_protocols(&mut self) -> &mut WebSocketRequestBuilder<B>
pub fn unset_protocols(&mut self) -> &mut WebSocketRequestBuilder<B>
Define the WebSocket protocols to be used.
pub fn maybe_with_key(
self,
key: Option<SecWebSocketKey>,
) -> WebSocketRequestBuilder<B>
pub fn maybe_with_key( self, key: Option<SecWebSocketKey>, ) -> WebSocketRequestBuilder<B>
Set the WebSocket key (a random one will be generated if not defined).
Only touch this property if you have a good reason to do so.
pub fn maybe_set_key(
&mut self,
key: Option<SecWebSocketKey>,
) -> &mut WebSocketRequestBuilder<B>
pub fn maybe_set_key( &mut self, key: Option<SecWebSocketKey>, ) -> &mut WebSocketRequestBuilder<B>
Set the WebSocket key (a random one will be generated if not defined).
Only touch this property if you have a good reason to do so.
pub fn with_key(self, key: SecWebSocketKey) -> WebSocketRequestBuilder<B>
pub fn with_key(self, key: SecWebSocketKey) -> WebSocketRequestBuilder<B>
Set the WebSocket key (a random one will be generated if not defined).
Only touch this property if you have a good reason to do so.
pub fn set_key(
&mut self,
key: SecWebSocketKey,
) -> &mut WebSocketRequestBuilder<B>
pub fn set_key( &mut self, key: SecWebSocketKey, ) -> &mut WebSocketRequestBuilder<B>
Set the WebSocket key (a random one will be generated if not defined).
Only touch this property if you have a good reason to do so.
pub fn without_key(self) -> WebSocketRequestBuilder<B>
pub fn without_key(self) -> WebSocketRequestBuilder<B>
Set the WebSocket key (a random one will be generated if not defined).
Only touch this property if you have a good reason to do so.
pub fn unset_key(&mut self) -> &mut WebSocketRequestBuilder<B>
pub fn unset_key(&mut self) -> &mut WebSocketRequestBuilder<B>
Set the WebSocket key (a random one will be generated if not defined).
Only touch this property if you have a good reason to do so.
Trait Implementations§
§impl<B> Clone for WebSocketRequestBuilder<B>where
B: Clone,
impl<B> Clone for WebSocketRequestBuilder<B>where
B: Clone,
§fn clone(&self) -> WebSocketRequestBuilder<B>
fn clone(&self) -> WebSocketRequestBuilder<B>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<B> !Freeze for WebSocketRequestBuilder<B>
impl<B> RefUnwindSafe for WebSocketRequestBuilder<B>where
B: RefUnwindSafe,
impl<B> Send for WebSocketRequestBuilder<B>where
B: Send,
impl<B> Sync for WebSocketRequestBuilder<B>where
B: Sync,
impl<B> Unpin for WebSocketRequestBuilder<B>where
B: Unpin,
impl<B> UnwindSafe for WebSocketRequestBuilder<B>where
B: UnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more