pub struct Client<S> { /* private fields */ }Expand description
HTTP/1.1 keep-alive connection — pure transport.
Sends request bytes and reads response bytes. All protocol logic
lives in RequestWriter (request encoding) and
ResponseReader (response parsing).
§Usage
use nexus_web::rest::{Client, RequestWriter};
use nexus_web::http::ResponseReader;
use nexus_web::tls::TlsConfig;
// Protocol (sans-IO)
let mut writer = RequestWriter::new("api.binance.com").unwrap();
let mut reader = ResponseReader::new(32 * 1024);
// Transport
let tls = TlsConfig::new()?;
let mut conn = Client::builder().tls(&tls).connect("https://api.binance.com")?;
// Build + send
let req = writer.get("/orders").query("symbol", "BTC").finish()?;
let resp = conn.send(req, &mut reader)?;Implementations§
Source§impl Client<TcpStream>
impl Client<TcpStream>
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Create a transport builder.
Source§impl<S> Client<S>
impl<S> Client<S>
Sourcepub fn is_poisoned(&self) -> bool
pub fn is_poisoned(&self) -> bool
Whether the connection is poisoned (I/O error occurred).
Sourcepub fn stream_mut(&mut self) -> &mut S
pub fn stream_mut(&mut self) -> &mut S
Mutable access to the underlying stream.
Source§impl<S: Read + Write> Client<S>
impl<S: Read + Write> Client<S>
Sourcepub fn send<'r>(
&mut self,
req: Request<'_>,
reader: &'r mut ResponseReader,
) -> Result<RestResponse<'r>, RestError>
pub fn send<'r>( &mut self, req: Request<'_>, reader: &'r mut ResponseReader, ) -> Result<RestResponse<'r>, RestError>
Send a request and read the response.
req provides the outbound bytes (from RequestWriter).
reader receives and parses the response (body size limit
configured on the reader via ResponseReader::max_body_size).
Read timeout is a stream-level concern — configure via the builder
(read_timeout) or conn.stream().set_read_timeout() for
TcpStream. Without a timeout, reads block indefinitely.
Response borrows from reader — drop before next send.