pub struct TcpClient {
pub host: String,
pub port: u16,
}Available on crate features
tcp-client and client only.Expand description
The TCP client.
This Client uses the TCP protocol to connect to a listener, to
read responses and write requests.
Fields§
§host: StringThe TCP host the client should connect to.
port: u16The TCP port the client should connect to.
Implementations§
Trait Implementations§
source§impl Client for TcpClient
impl Client for TcpClient
source§fn send(&self, req: Request) -> Result<Response>
fn send(&self, req: Request) -> Result<Response>
Send the given request to the TCP server.
To send a request, the TcpClient retrieves the
std::net::TcpStream by connecting to the server, then
handles it using the helper crate::ClientStream::handle.
fn start(&self) -> Result<()>
fn get(&self) -> Result<Timer>
fn set(&self, duration: usize) -> Result<()>
fn pause(&self) -> Result<()>
fn resume(&self) -> Result<()>
fn stop(&self) -> Result<()>
source§impl ClientStream<TcpStream> for TcpClient
impl ClientStream<TcpStream> for TcpClient
source§fn read(&self, stream: &TcpStream) -> Result<Response>
fn read(&self, stream: &TcpStream) -> Result<Response>
Read the given std::net::TcpStream to extract the response
sent by the server.
source§fn write(&self, stream: &mut TcpStream, req: Request) -> Result<()>
fn write(&self, stream: &mut TcpStream, req: Request) -> Result<()>
Write the given request to the given std::net::TcpStream.
fn handle(&self, stream: &mut T, req: Request) -> Result<Response>
Auto Trait Implementations§
impl RefUnwindSafe for TcpClient
impl Send for TcpClient
impl Sync for TcpClient
impl Unpin for TcpClient
impl UnwindSafe for TcpClient
Blanket Implementations§
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
Mutably borrows from an owned value. Read more