[−][src]Struct message_io::network::NetworkManager
NetworkManager allows to manage the network easier. It is in mainly in charge to transform raw data from the network into message events and vice versa.
Implementations
impl<'a> NetworkManager
[src]
pub fn new<InMessage, C>(event_callback: C) -> NetworkManager where
InMessage: for<'b> Deserialize<'b> + Send + 'static,
C: Fn(NetEvent<InMessage>) + Send + 'static,
[src]
InMessage: for<'b> Deserialize<'b> + Send + 'static,
C: Fn(NetEvent<InMessage>) + Send + 'static,
Creates a new NetworkManager. The user must register an event_callback that can be called each time the network generate and NetEvent
pub fn connect(
&mut self,
addr: SocketAddr,
transport: TransportProtocol
) -> Option<(Endpoint, SocketAddr)>
[src]
&mut self,
addr: SocketAddr,
transport: TransportProtocol
) -> Option<(Endpoint, SocketAddr)>
Creates a connection to the specific address thougth the given protocol. The endpoint, an identified of the new connection, will be returned among with the local address of that connection. Only for TCP, if the connection can not be performed (the address is not reached) a None will be returned. UDP has no the ability to be aware of this, so always an endpoint will be returned.
pub fn listen(
&mut self,
addr: SocketAddr,
transport: TransportProtocol
) -> Option<(Endpoint, SocketAddr)>
[src]
&mut self,
addr: SocketAddr,
transport: TransportProtocol
) -> Option<(Endpoint, SocketAddr)>
Open a port to listen messages from either TCP or UDP. If the port can be opened, a endpoint identifying the listener will be returned among with the local address, or a None if not.
pub fn endpoint_local_address(
&mut self,
endpoint: Endpoint
) -> Option<SocketAddr>
[src]
&mut self,
endpoint: Endpoint
) -> Option<SocketAddr>
Retrieve the local address associated to an endpoint, or None if the endpoint does not exists.
pub fn endpoint_remote_address(
&mut self,
endpoint: Endpoint
) -> Option<SocketAddr>
[src]
&mut self,
endpoint: Endpoint
) -> Option<SocketAddr>
Retrieve the address associated to an endpoint, or None if the endpoint does not exists or the endpoint is a listener.
pub fn remove_endpoint(&mut self, endpoint: Endpoint) -> Option<()>
[src]
Remove the endpoint. Returns None if the endpoint does not exists.
pub fn send<OutMessage>(
&mut self,
endpoint: Endpoint,
message: OutMessage
) -> Option<()> where
OutMessage: Serialize,
[src]
&mut self,
endpoint: Endpoint,
message: OutMessage
) -> Option<()> where
OutMessage: Serialize,
Serialize and send the message thought the connection represented by the given endpoint. Returns None if the endpoint does not exists.
pub fn send_all<'b, OutMessage>(
&mut self,
endpoints: impl IntoIterator<Item = &'b Endpoint>,
message: OutMessage
) -> Result<(), Vec<Endpoint>> where
OutMessage: Serialize,
[src]
&mut self,
endpoints: impl IntoIterator<Item = &'b Endpoint>,
message: OutMessage
) -> Result<(), Vec<Endpoint>> where
OutMessage: Serialize,
Serialize and send the message thought the connections represented by the given endpoints.
When there are severals endpoints to send the data. It is better to call this function instead of several calls to send()
,
because the serialization only is performed one time for all the endpoints.
An Err with the unrecognized ids is returned.
Trait Implementations
impl Drop for NetworkManager
[src]
Auto Trait Implementations
impl !RefUnwindSafe for NetworkManager
impl Send for NetworkManager
impl Sync for NetworkManager
impl Unpin for NetworkManager
impl !UnwindSafe for NetworkManager
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,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
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>,