pub struct Net { /* private fields */ }Expand description
Net is the main interface to the network stack.
Socket creation and configuration is done through the Net interface.
When Net is dropped, all sockets are closed and the network stack is stopped.
Implementations§
Source§impl Net
impl Net
Sourcepub fn new<D: AsyncDevice + 'static>(device: D, config: NetConfig) -> Net
pub fn new<D: AsyncDevice + 'static>(device: D, config: NetConfig) -> Net
Creates a new Net instance. It panics if the medium is not supported.
Sourcepub async fn tcp_bind(&self, addr: SocketAddr) -> Result<TcpListener>
pub async fn tcp_bind(&self, addr: SocketAddr) -> Result<TcpListener>
Creates a new TcpListener, which will be bound to the specified address.
Sourcepub async fn tcp_connect(&self, addr: SocketAddr) -> Result<TcpStream>
pub async fn tcp_connect(&self, addr: SocketAddr) -> Result<TcpStream>
Opens a TCP connection to a remote host.
pub fn tcp_connect_lazy( &self, addr: SocketAddr, ) -> (SocketAddr, impl Future<Output = Result<TcpStream, Error>>)
Sourcepub async fn udp_bind(&self, addr: SocketAddr) -> Result<UdpSocket>
pub async fn udp_bind(&self, addr: SocketAddr) -> Result<UdpSocket>
This function will create a new UDP socket and attempt to bind it to the addr provided.
Sourcepub async fn raw_socket(
&self,
ip_version: IpVersion,
ip_protocol: IpProtocol,
) -> Result<RawSocket>
pub async fn raw_socket( &self, ip_version: IpVersion, ip_protocol: IpProtocol, ) -> Result<RawSocket>
Creates a new raw socket.
Sourcepub fn set_any_ip(&self, any_ip: bool)
pub fn set_any_ip(&self, any_ip: bool)
Enable or disable the AnyIP capability.
pub fn routes<F: FnOnce(&Routes)>(&self, f: F)
pub fn routes_mut<F: FnOnce(&mut Routes)>(&self, f: F)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Net
impl !RefUnwindSafe for Net
impl Send for Net
impl Sync for Net
impl Unpin for Net
impl !UnwindSafe for Net
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more