Skip to main content

TcpServerRouter

Struct TcpServerRouter 

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

Tcp server router. Handles the every data route destination

Implementations§

Source§

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

Source

pub fn new(user_s_type: Box<dyn StructureType>) -> Self

Returns the new instance of router

‘user_s_type’ random enum value of current project defined structure_type

Source

pub fn add_route( &mut self, handler: Arc<Mutex<dyn Handler<Codec = C>>>, handler_name: String, s_types: Vec<Box<dyn StructureType>>, )

Registers the new handler, for selected structure types

‘handler_name’ must be the same on the client site, used for initial identification. When client sends request to server. ‘s_type’ handled structure types by current handler.

Source

pub fn commit_routes(&mut self)

Commits the registered handlers. Making the current router is final and ready to be passed to the server

Source

pub fn get_routes( &self, ) -> Arc<HashMap<TypeTupple, Arc<Mutex<dyn Handler<Codec = C>>>>>

Source

pub async fn serve_packet( &self, meta: BytesMut, payload: BytesMut, client_meta: (SocketAddr, &mut Option<Sender<Arc<Mutex<dyn Handler<Codec = C>>>>>), ) -> Result<Vec<u8>, ServerError>

Called from server connection task

Auto Trait Implementations§

§

impl<C> Freeze for TcpServerRouter<C>

§

impl<C> !RefUnwindSafe for TcpServerRouter<C>

§

impl<C> Send for TcpServerRouter<C>

§

impl<C> Sync for TcpServerRouter<C>

§

impl<C> Unpin for TcpServerRouter<C>

§

impl<C> !UnwindSafe for TcpServerRouter<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