pub struct ClientBuilder { /* private fields */ }Expand description
Builder for Client.
Configures transport: TLS, timeouts, socket options.
Protocol configuration (host, headers, base path) lives on
RequestWriter.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn tls(self, config: &TlsConfig) -> Self
pub fn tls(self, config: &TlsConfig) -> Self
Set a custom TLS configuration.
If not set, https:// URLs use TlsConfig::new() (system defaults).
Sourcepub fn disable_nagle(self) -> Self
pub fn disable_nagle(self) -> Self
Set TCP_NODELAY (disable Nagle’s algorithm).
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 connect(
self,
url: &str,
) -> Result<Client<MaybeTls<TcpStream>>, RestError>
pub fn connect( self, url: &str, ) -> Result<Client<MaybeTls<TcpStream>>, RestError>
Connect to an HTTP(S) endpoint (blocking).
TLS is auto-detected from the URL scheme. When the tls feature is
enabled, returns Client<MaybeTls<TcpStream>> — https:// uses
MaybeTls::Tls, http:// uses MaybeTls::Plain. Without the tls
feature, returns Client<TcpStream> and errors on https://.
Sourcepub fn connect_with<S: Read + Write>(
self,
stream: S,
url: &str,
) -> Result<Client<S>, RestError>
pub fn connect_with<S: Read + Write>( self, stream: S, url: &str, ) -> Result<Client<S>, RestError>
Connect using a pre-connected socket.
The stream must already handle TLS if connecting to https://.
For example, pass a TlsStream<TcpStream> or MaybeTls<TcpStream>.
Sourcepub fn writer_for(url: &str) -> Result<RequestWriter, RestError>
pub fn writer_for(url: &str) -> Result<RequestWriter, RestError>
Create a RequestWriter configured for this URL.
Convenience: extracts host and path from the URL to create a writer with the correct Host header and base path.