Struct riptun::TokioTun [−][src]
pub struct TokioTun { /* fields omitted */ }
Expand description
An asynchronous virtual TUN device based on the tokio
ecosystem.
Implementations
Create a new multi-queue async Tun device, supporting the tokio
ecosystem, using the
specified name and number of queues. The name parameter can be augmented with %d
to
denote a OS determined incrementing ID to assign this device. To get the real device
name call TokioTun::name()
.
Retrieve an immutable reference to the specified queue(s) if the suplied SliceIndex is inbounds.
pub fn get_mut<I>(&mut self, index: I) -> Option<&mut I::Output> where
I: SliceIndex<[TokioQueue]>,
pub fn get_mut<I>(&mut self, index: I) -> Option<&mut I::Output> where
I: SliceIndex<[TokioQueue]>,
Retrieve a mutable reference to the specified queue(s) if the suplied SliceIndex is inbounds.
Close the device destroying all internal queues.
NOTE: If drain
is called its on the caller to cleanup the queues.
Drain the internal queues, passing ownership of the queue and its lifecycle to the caller. This is useful in certain scenarios where extreme control over threading and I/O operations is desired.
Iterate over immutable instances internal queues.
Iterate over mutable instances of the internal queues.
Send a packet asynchronously to an available queue. This method handles collecting
all of the TokioQueue::writable()
futures. Then leverages [select_all()
] to await the
first available queue to send the datagram via.
Send a packet asynchronously via the specified TUN queue, see the TokioQueue::send()
documentation for more details.
Errors
General I/O errors are possible, along with a Error::InvalidQueue if the specified queue is out of range for this device.
Receive a packet asynchronously from an available queue. This method handles collecting
all of the TokioQueue::readable()
futures. Then leverages [select_all()
] to await the
first available queue to send the datagram via.
Receive a packet asynchronously from the specified TUN queue, see the TokioQueue::recv()
documentation for more details.
Errors
General I/O errors are possible, along with a Error::InvalidQueue if the specified queue is out of range for this device.
Trait Implementations
type Output = TokioQueue
type Output = TokioQueue
The returned type after indexing.
Performs the indexing (container[index]
) operation. Read more
Performs the mutable indexing (container[index]
) operation. Read more
type Item = TokioQueue
type Item = TokioQueue
The type of the elements being iterated over.
type IntoIter = IntoIter<TokioQueue>
type IntoIter = IntoIter<TokioQueue>
Which kind of iterator are we turning this into?