Struct gjio::Network [] [src]

pub struct Network {
    // some fields omitted
}

Mediates the creation of async-enabled sockets.

It is good practice to limit the use of this struct to high-level startup code and user interaction.

Methods

impl Network
[src]

fn get_tcp_address(&self, addr: SocketAddr) -> SocketAddress

fn get_unix_address<P: AsRef<Path>>(&self, addr: P) -> Result<SocketAddressError>

fn new_socket_pair(&self) -> Result<(SocketStream, SocketStream)Error>

fn wrap_std_tcp_stream(&self, stream: TcpStream) -> Result<SocketStreamError>

Transforms the std::net::TcpStream into a SocketStream.

unsafe fn wrap_raw_socket_descriptor(&self, fd: RawDescriptor) -> Result<SocketStreamError>

Wraps a raw file descriptor into a SocketStream. The SocketStream assumes ownership over the descriptor and will close it when the SocketStream is dropped. This method is unsafe because the caller needs to ensure that the descriptor is valid and not owned by anyone else.

A safer (and windows-compatible) way to transform a TcpStream into a SocketStream is via from_std_tcp_stream.

fn socket_spawn<F>(&self, start_func: F) -> Result<(JoinHandle<()>, SocketStream)Box<Error>> where F: FnOnce(SocketStream, &WaitScope, EventPort) -> Result<()Box<Error>>, F: Send + 'static

Creates a new thread and sets up a socket pair that can be used to communicate with it. Passes one of the sockets to the thread's start function and returns the other socket. The new thread will already have an active event loop when start_func is called.

Trait Implementations

impl Clone for Network
[src]

fn clone(&self) -> Network

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more