Struct time::TcpBind

source ·
pub struct TcpBind {
    pub host: String,
    pub port: u16,
}
Available on crate features tcp-binder and server only.
Expand description

The TCP server binder.

This ServerBinder uses the TCP protocol to bind a listener, to read requests and write responses.

Fields§

§host: String

The TCP host of the listener.

§port: u16

The TCP port of the listener.

Implementations§

source§

impl TcpBind

source

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

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

Trait Implementations§

source§

impl ServerBind for TcpBind

source§

fn bind(&self, timer: ThreadSafeTimer) -> Result<()>

Bind the TCP listener.

To bind, the TcpBind gets a std::net::TcpListener then indefinitely waits for incoming requests. When a connection comes, TcpBind retrieves the associated std::net::TcpStream and send it to the helper crate::ServerStream::handle.

source§

impl ServerStream<TcpStream> for TcpBind

source§

fn read(&self, stream: &TcpStream) -> Result<Request>

Read the given std::net::TcpStream to extract the request sent by the client.

source§

fn write(&self, stream: &mut TcpStream, res: Response) -> Result<()>

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

source§

fn handle(&self, timer: ThreadSafeTimer, stream: &mut T) -> Result<()>

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.