Struct websocket_lite::ClientBuilder
source · [−]pub struct ClientBuilder { /* private fields */ }
Expand description
Establishes a WebSocket connection.
ws://...
and wss://...
URLs are supported.
Implementations
sourceimpl ClientBuilder
impl ClientBuilder
sourcepub fn new(url: &str) -> Result<Self, ParseError>
pub fn new(url: &str) -> Result<Self, ParseError>
Creates a ClientBuilder
that connects to a given WebSocket URL.
This method returns an Err
result if URL parsing fails.
sourcepub fn from_url(url: Url) -> Self
pub fn from_url(url: Url) -> Self
Creates a ClientBuilder
that connects to a given WebSocket URL.
This method never fails as the URL has already been parsed.
sourcepub fn add_header(&mut self, name: String, value: String)
pub fn add_header(&mut self, name: String, value: String)
Adds an extra HTTP header for client
sourcepub async fn async_connect_insecure(self) -> Result<AsyncClient<TokioTcpStream>>
pub async fn async_connect_insecure(self) -> Result<AsyncClient<TokioTcpStream>>
Establishes a connection to the WebSocket server.
wss://...
URLs are not supported by this method. Use async_connect
if you need to be able to handle
both ws://...
and wss://...
URLs.
sourcepub fn connect_insecure(self) -> Result<Client<StdTcpStream>>
pub fn connect_insecure(self) -> Result<Client<StdTcpStream>>
Establishes a connection to the WebSocket server.
wss://...
URLs are not supported by this method. Use connect
if you need to be able to handle
both ws://...
and wss://...
URLs.
sourcepub async fn async_connect(
self
) -> Result<AsyncClient<Box<dyn AsyncNetworkStream + Sync + Send + Unpin + 'static>>>
pub async fn async_connect(
self
) -> Result<AsyncClient<Box<dyn AsyncNetworkStream + Sync + Send + Unpin + 'static>>>
Establishes a connection to the WebSocket server.
sourcepub fn connect(
self
) -> Result<Client<Box<dyn NetworkStream + Sync + Send + 'static>>>
pub fn connect(
self
) -> Result<Client<Box<dyn NetworkStream + Sync + Send + 'static>>>
Establishes a connection to the WebSocket server.
sourcepub async fn async_connect_on<S: AsyncRead + AsyncWrite + Unpin>(
self,
stream: S
) -> Result<AsyncClient<S>>
pub async fn async_connect_on<S: AsyncRead + AsyncWrite + Unpin>(
self,
stream: S
) -> Result<AsyncClient<S>>
Takes over an already established stream and uses it to send and receive WebSocket messages.
This method assumes that the TLS connection has already been established, if needed. It sends an HTTP
Connection: Upgrade
request and waits for an HTTP OK response before proceeding.
sourcepub fn connect_on<S: Read + Write>(self, stream: S) -> Result<Client<S>>
pub fn connect_on<S: Read + Write>(self, stream: S) -> Result<Client<S>>
Takes over an already established stream and uses it to send and receive WebSocket messages.
This method assumes that the TLS connection has already been established, if needed. It sends an HTTP
Connection: Upgrade
request and waits for an HTTP OK response before proceeding.
Auto Trait Implementations
impl RefUnwindSafe for ClientBuilder
impl Send for ClientBuilder
impl Sync for ClientBuilder
impl Unpin for ClientBuilder
impl UnwindSafe for ClientBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more