Struct message_io::network::NetworkController [−][src]
Shareable instance in charge of control all the connections.
Implementations
impl NetworkController
[src]
pub fn connect(
&self,
transport: Transport,
addr: impl ToRemoteAddr
) -> Result<(Endpoint, SocketAddr)>
[src]
&self,
transport: Transport,
addr: impl ToRemoteAddr
) -> Result<(Endpoint, SocketAddr)>
Creates a connection to the specific address. The endpoint, an identifier of the new connection, will be returned. If the connection can not be performed (e.g. the address is not reached) the corresponding IO error is returned. This function blocks until the resource has been connected and is ready to use.
pub fn listen(
&self,
transport: Transport,
addr: impl ToSocketAddrs
) -> Result<(ResourceId, SocketAddr)>
[src]
&self,
transport: Transport,
addr: impl ToSocketAddrs
) -> Result<(ResourceId, SocketAddr)>
Listen messages from specified transport.
The giver address will be used as interface and listening port.
If the port can be opened, a ResourceId identifying the listener is returned
along with the local address, or an error if not.
The address is returned despite you passed as parameter because
when a 0
port is specified, the OS will give choose the value.
pub fn remove(&self, resource_id: ResourceId) -> bool
[src]
Remove a network resource.
Returns false
if the resource id doesn’t exists.
This is used to remove resources as connection or listeners.
Resources of endpoints generated by listening in connection oriented transports
can also be removed to close the connection.
Removing an already connected connection implies a disconnection.
Note that non-oriented connections as UDP use its listener resource to manage all
remote endpoints internally, the remotes have not resource for themselfs.
It means that all generated Endpoint
s share the ResourceId
of the listener and
if you remove this resource you are removing the listener of all of them.
For that cases there is no need to remove the resource because non-oriented connections
have not connection itself to close, ‘there is no spoon’.
pub fn send(&self, endpoint: Endpoint, data: &[u8]) -> SendStatus
[src]
Send the data message thought the connection represented by the given endpoint.
This function returns a SendStatus
indicating the status of this send.
There is no guarantee that send over a correct connection generates a SendStatus::Sent
because any time a connection can be disconnected (even while you are sending).
Except cases where you need to be sure that the message has been sent,
you will want to process a NetEvent::Disconnected
to determine if the connection +
is alive instead of check if send()
returned SendStatus::ResourceNotFound
.
Auto Trait Implementations
impl !RefUnwindSafe for NetworkController
impl Send for NetworkController
impl Sync for NetworkController
impl Unpin for NetworkController
impl UnwindSafe for NetworkController
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, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
type Output = T
Should always be Self
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>,