pub struct Netstack<D> { /* private fields */ }Expand description
A userspace network stack.
This is a relatively thin shell around CoreStack to provide convenience runtime
features.
Implementations§
Source§impl<D> Netstack<D>
impl<D> Netstack<D>
Sourcepub fn with_clock(dev: D, config: Config, clock: Clock) -> Self
pub fn with_clock(dev: D, config: Config, clock: Clock) -> Self
Construct a new netstack with the given device, configuration, and clock.
Sourcepub fn run_blocking(&mut self, poll_delay: Duration)where
D: Device,
pub fn run_blocking(&mut self, poll_delay: Duration)where
D: Device,
Run the netstack, driving the internal event loop to consume commands.
Runs forever, blocking the current thread.
poll_delay is the amount of time to sleep when we’re done with I/O and commands to
process: a smaller delay improves latency at the cost of CPU cycles spent polling.
Consider the async methods for an event-driven approach.
Sourcepub async fn run_with_sleep(&mut self, sleep: impl AsyncFn(Duration) + Clone)
pub async fn run_with_sleep(&mut self, sleep: impl AsyncFn(Duration) + Clone)
Run the netstack, driving the internal event loop to consume commands.
The sleep function is the runtime-specific sleep implementation. It has the
Clone bound for esoteric async type system reasons (the loop needs to call the
function multiple times, but it doesn’t want to reason about &impl AsyncFn). A
normal closure or async fn ref will satisfy the bound.
Trait Implementations§
Source§impl<D> HasChannel for Netstack<D>
impl<D> HasChannel for Netstack<D>
Source§fn command_channel(&self) -> WeakSender<Request>
fn command_channel(&self) -> WeakSender<Request>
Source§fn request_blocking(
&self,
handle: Option<SocketHandle>,
command: impl Into<Command>,
) -> Result<Response, ChannelClosedError>
fn request_blocking( &self, handle: Option<SocketHandle>, command: impl Into<Command>, ) -> Result<Response, ChannelClosedError>
Source§fn request(
&self,
handle: Option<SocketHandle>,
command: impl Into<Command>,
) -> impl Future<Output = Result<Response, Error>> + Send
fn request( &self, handle: Option<SocketHandle>, command: impl Into<Command>, ) -> impl Future<Output = Result<Response, Error>> + Send
Source§fn request_nonblocking(
&self,
handle: Option<SocketHandle>,
command: impl Into<Command>,
) -> Result<(), ChannelClosedError>
fn request_nonblocking( &self, handle: Option<SocketHandle>, command: impl Into<Command>, ) -> Result<(), ChannelClosedError>
Auto Trait Implementations§
impl<D> !RefUnwindSafe for Netstack<D>
impl<D> !UnwindSafe for Netstack<D>
impl<D> Freeze for Netstack<D>where
D: Freeze,
impl<D> Send for Netstack<D>where
D: Send,
impl<D> Sync for Netstack<D>where
D: Sync,
impl<D> Unpin for Netstack<D>where
D: Unpin,
impl<D> UnsafeUnpin for Netstack<D>where
D: UnsafeUnpin,
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
Source§impl<T> CreateSocket for Twhere
T: HasChannel + Sync,
impl<T> CreateSocket for Twhere
T: HasChannel + Sync,
Source§fn udp_bind_blocking(&self, endpoint: SocketAddr) -> Result<UdpSocket, Error>
fn udp_bind_blocking(&self, endpoint: SocketAddr) -> Result<UdpSocket, Error>
UdpSocket to the given local endpoint.Source§async fn udp_bind(&self, endpoint: SocketAddr) -> Result<UdpSocket, Error>
async fn udp_bind(&self, endpoint: SocketAddr) -> Result<UdpSocket, Error>
UdpSocket to the given local endpoint.Source§fn tcp_listen_blocking(
&self,
local_endpoint: SocketAddr,
) -> Result<TcpListener, Error>
fn tcp_listen_blocking( &self, local_endpoint: SocketAddr, ) -> Result<TcpListener, Error>
TcpListener on the given endpoint.Source§async fn tcp_listen(
&self,
local_endpoint: SocketAddr,
) -> Result<TcpListener, Error>
async fn tcp_listen( &self, local_endpoint: SocketAddr, ) -> Result<TcpListener, Error>
TcpListener on the given endpoint.Source§fn bound_tcp_ports_blocking(&self) -> Result<Vec<u16>, Error>
fn bound_tcp_ports_blocking(&self) -> Result<Vec<u16>, Error>
Source§async fn bound_tcp_ports(&self) -> Result<Vec<u16>, Error>
async fn bound_tcp_ports(&self) -> Result<Vec<u16>, Error>
CreateSocket::bound_tcp_ports_blocking.