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]
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,
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]
&self,
message: NetworkMessage<T>,
timeout: Option<Duration>,
react: Option<Action<T, E>>
) -> Result<(), Error<E>>
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> HandlerError for T where
T: Send + Sync + Debug + 'static + Clone,
[src]
T: Send + Sync + Debug + 'static + Clone,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,