Struct netty_rs::Networker[][src]

pub struct Networker<T: NetworkContent + 'static, E: HandlerError> { /* fields omitted */ }

This struct is the main API for using netty. It allows the creation of a server and the ability to send messages to clients.

Implementations

impl<T: NetworkContent, E: HandlerError> Networker<T, E>[src]

pub async fn new<H, M, FH, FM>(
    address: SocketAddr,
    directory_service: impl DirectoryService<String, E> + 'static,
    handle_handshakes: H,
    handle_messages: M
) -> Result<Networker<T, E>, Error<E>> where
    FM: Future<Output = Result<(), Error<E>>> + Send,
    FH: Future<Output = Result<String, Error<E>>> + Send,
    M: FnMut(NetworkMessage<T>, Connection<T, E>) -> FM + Send + Sync + Clone + 'static,
    H: FnMut(NetworkMessage<T>, Connection<T, E>) -> FH + Send + Sync + Clone + 'static, 
[src]

Creates a new networker using. address is the network socket address that the server should listen to. directory_service is the directory service to use in order to translate IDs to addresses. handle_handshakes is a closure that is called when a new connection is recieved which sends a NetworkMessage. This closure should authenticate if appropriate and do other handshake and setup related things. handle_messages is a closure that is called for all messages received from a connection that has already been handshaked.

pub async fn send_message(
    &self,
    message: NetworkMessage<T>,
    timeout: Option<Duration>,
    react: Option<Action<T, E>>
) -> Result<(), Error<E>>
[src]

Sends a message and then reacts to the response with the action and then returns the last message returned

pub async fn listen(&self, should_listen: bool) -> Result<(), Error<E>>[src]

Starts the server

Trait Implementations

impl<T: Clone + NetworkContent + 'static, E: Clone + HandlerError> Clone for Networker<T, E>[src]

impl<T: Debug + NetworkContent + 'static, E: Debug + HandlerError> Debug for Networker<T, E>[src]

Auto Trait Implementations

impl<T, E> !RefUnwindSafe for Networker<T, E>

impl<T, E> Send for Networker<T, E>

impl<T, E> Sync for Networker<T, E>

impl<T, E> Unpin for Networker<T, E>

impl<T, E> !UnwindSafe for Networker<T, E>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> HandlerError for T where
    T: Send + Sync + Debug + 'static + Clone
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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