Net

Struct Net 

Source
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

Source

pub fn new<D: AsyncDevice + 'static>(device: D, config: NetConfig) -> Net

Creates a new Net instance. It panics if the medium is not supported.

Source

pub async fn tcp_bind(&self, addr: SocketAddr) -> Result<TcpListener>

Creates a new TcpListener, which will be bound to the specified address.

Source

pub async fn tcp_connect(&self, addr: SocketAddr) -> Result<TcpStream>

Opens a TCP connection to a remote host.

Source

pub fn tcp_connect_lazy( &self, addr: SocketAddr, ) -> (SocketAddr, impl Future<Output = Result<TcpStream, Error>>)

Source

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.

Source

pub async fn raw_socket( &self, ip_version: IpVersion, ip_protocol: IpProtocol, ) -> Result<RawSocket>

Creates a new raw socket.

Source

pub fn set_any_ip(&self, any_ip: bool)

Enable or disable the AnyIP capability.

Source

pub fn any_ip(&self) -> bool

Get whether AnyIP is enabled.

Source

pub fn routes<F: FnOnce(&Routes)>(&self, f: F)

Source

pub fn routes_mut<F: FnOnce(&mut Routes)>(&self, f: F)

Trait Implementations§

Source§

impl Drop for Net

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.