Struct time::client::TcpClient

source ·
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: String

The TCP host the client should connect to.

§port: u16

The TCP port the client should connect to.

Implementations§

source§

impl TcpClient

source

pub fn new(host: impl ToString, port: u16) -> Box<dyn Client>

Create a new TCP client using the given host and port.

Trait Implementations§

source§

impl Client for TcpClient

source§

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.

source§

fn start(&self) -> Result<()>

source§

fn get(&self) -> Result<Timer>

source§

fn set(&self, duration: usize) -> Result<()>

source§

fn pause(&self) -> Result<()>

source§

fn resume(&self) -> Result<()>

source§

fn stop(&self) -> Result<()>

source§

impl ClientStream<TcpStream> for TcpClient

source§

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<()>

Write the given request to the given std::net::TcpStream.

source§

fn handle(&self, stream: &mut T, req: Request) -> Result<Response>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.