pub struct ClientBuilder { /* private fields */ }Expand description
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn begin_connect<S: Read + Write>(
self,
stream: S,
url: &str,
) -> Result<Connecting<S>, Error>
pub fn begin_connect<S: Read + Write>( self, stream: S, url: &str, ) -> Result<Connecting<S>, Error>
Start a non-blocking connection handshake.
Returns a Connecting that must be driven to completion
via poll() before messages can be sent/received.
The caller is responsible for setting the socket to non-blocking mode before calling this.
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn buffer_capacity(self, n: usize) -> Self
pub fn buffer_capacity(self, n: usize) -> Self
ReadBuf capacity. Default: 1MB.
Sourcepub fn max_frame_size(self, n: u64) -> Self
pub fn max_frame_size(self, n: u64) -> Self
Maximum single frame payload. Default: 16MB.
Sourcepub fn max_message_size(self, n: usize) -> Self
pub fn max_message_size(self, n: usize) -> Self
Maximum assembled message size. Default: 16MB.
Sourcepub fn write_buffer_capacity(self, n: usize) -> Self
pub fn write_buffer_capacity(self, n: usize) -> Self
Write buffer capacity. Default: 64KB.
Sourcepub fn disable_nagle(self) -> Self
pub fn disable_nagle(self) -> Self
Set TCP_NODELAY (disable Nagle’s algorithm).
Sourcepub fn recv_buffer_size(self, n: usize) -> Self
pub fn recv_buffer_size(self, n: usize) -> Self
Set SO_RCVBUF (socket receive buffer size).
Sourcepub fn send_buffer_size(self, n: usize) -> Self
pub fn send_buffer_size(self, n: usize) -> Self
Set SO_SNDBUF (socket send buffer size).
Sourcepub fn connect_timeout(self, d: Duration) -> Self
pub fn connect_timeout(self, d: Duration) -> Self
TCP connect timeout.
Sourcepub fn read_timeout(self, d: Duration) -> Self
pub fn read_timeout(self, d: Duration) -> Self
Socket read timeout.
Sourcepub fn tls(self, config: &TlsConfig) -> Self
pub fn tls(self, config: &TlsConfig) -> Self
Set a custom TLS configuration.
If not set, wss:// URLs use TlsConfig::new() (system defaults).
Sourcepub fn connect(self, url: &str) -> Result<Client<MaybeTls<TcpStream>>, Error>
pub fn connect(self, url: &str) -> Result<Client<MaybeTls<TcpStream>>, Error>
Connect to a WebSocket server (blocking).
Creates a TCP socket, applies socket options, and performs the
full handshake (TLS if wss://, then HTTP upgrade).
When the tls feature is enabled, returns Client<MaybeTls<TcpStream>>
regardless of scheme — ws:// uses MaybeTls::Plain, wss:// uses
MaybeTls::Tls. Without the tls feature, returns Client<TcpStream>
and errors on wss://.
Sourcepub fn connect_with<S: Read + Write>(
self,
stream: S,
url: &str,
) -> Result<Client<S>, Error>
pub fn connect_with<S: Read + Write>( self, stream: S, url: &str, ) -> Result<Client<S>, Error>
Connect using a pre-connected stream.
The stream must already handle TLS if connecting to wss://.
For example, pass a TlsStream<TcpStream> or MaybeTls<TcpStream>.
This method only performs the HTTP upgrade handshake.