Skip to main content

TcpServer

Struct TcpServer 

Source
pub struct TcpServer<C>
where C: Encoder<Bytes, Error = Error> + Decoder<Item = BytesMut, Error = Error> + Send + Sync + Clone + 'static + TfCodec,
{ /* private fields */ }
Expand description

Base binary tcp server.

‘C’ is you codec, that you want to use to encode/decode data.

Recommended default codec is LengthDelimitedCodec, from the server codec module.

Implementations§

Source§

impl<C> TcpServer<C>
where C: Encoder<Bytes, Error = Error> + Decoder<Item = BytesMut, Error = Error> + Send + Sync + Clone + 'static + TfCodec,

Source

pub async fn new( bind_address: String, router: Arc<TcpServerRouter<C>>, processor: Option<TrafficProcessorHolder<C>>, codec: C, config: Option<ServerConfig>, ) -> Self

Creates a new instance of a server.

‘bind_address’ is a target address to bind current server. E.g: 0.0.0.0:8080 ‘router’ setted up router with handlers. Must be called commit_routes before using. ‘processor’ Custom traffic processor, used for all streams. ‘codec’ basically codec used for every stream with it’s own instance, when the codec is applied to stream, first call is clone, the second call is initial_setup. ‘config’ optional config for tls connection, when None the tls is not using, when some all connections are passed behind tls.

Source

pub async fn start(&mut self) -> JoinHandle<()>

Start the task for handling connections.

Return the join handle, of this task.

Source

pub fn send_stop(&self)

Stops the acceptor task.

Auto Trait Implementations§

§

impl<C> Freeze for TcpServer<C>
where C: Freeze,

§

impl<C> !RefUnwindSafe for TcpServer<C>

§

impl<C> Send for TcpServer<C>

§

impl<C> Sync for TcpServer<C>

§

impl<C> Unpin for TcpServer<C>
where C: Unpin,

§

impl<C> !UnwindSafe for TcpServer<C>

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V