pub struct AsyncSession { /* private fields */ }Implementations§
Methods from Deref<Target = Session>§
pub fn get_adapter(&self) -> Arc<Adapter> ⓘ
Sourcepub fn allocate_send_packet(
self: &Arc<Self>,
size: u16,
) -> Result<Packet, Error>
pub fn allocate_send_packet( self: &Arc<Self>, size: u16, ) -> Result<Packet, Error>
Allocates a send packet of the specified size. Wraps WintunAllocateSendPacket
All packets returned from this function must be sent using Session::send_packet because
wintun establishes the send packet order based on the invocation order of this function.
Therefore if a packet is allocated using this function, and then never sent, it will hold
up the send queue for all other packets allocated in the future. It is okay for the session
to shutdown with allocated packets that have not yet been sent
Sourcepub fn send_packet(&self, packet: Packet)
pub fn send_packet(&self, packet: Packet)
Sends a packet previously allocated with Session::allocate_send_packet
Sourcepub fn try_receive(self: &Arc<Self>) -> Result<Option<Packet>, Error>
pub fn try_receive(self: &Arc<Self>) -> Result<Option<Packet>, Error>
Attempts to receive a packet from the virtual interface without blocking.
If there are no packets currently in the receive queue, this function returns Ok(None)
without blocking. If blocking until a packet is desirable, use Session::receive_blocking
Sourcepub fn get_read_wait_event(&self) -> Result<UnsafeHandle<HANDLE>, Error>
pub fn get_read_wait_event(&self) -> Result<UnsafeHandle<HANDLE>, Error>
§Safety
Returns the low level read event handle that is signaled when more data becomes available to read
pub fn get_shutdown_event(&self) -> UnsafeHandle<HANDLE>
Sourcepub fn receive_blocking(self: &Arc<Self>) -> Result<Packet, Error>
pub fn receive_blocking(self: &Arc<Self>) -> Result<Packet, Error>
Blocks until a packet is available, returning the next packet in the receive queue once this happens.
If the session is closed via Session::shutdown all threads currently blocking inside this function
will return Err(())
pub fn wait_read(&self) -> Result<(), Error>
Sourcepub fn shutdown(&self) -> Result<(), Error>
pub fn shutdown(&self) -> Result<(), Error>
Cancels any active calls to Session::receive_blocking making them instantly return Err(_) so that session can be shutdown cleanly
pub fn try_recv(&self, buf: &mut [u8]) -> Result<usize>
Sourcepub fn recv(&self, buf: &mut [u8]) -> Result<usize>
pub fn recv(&self, buf: &mut [u8]) -> Result<usize>
Blocks until a packet is available, returning the next packet in the receive queue once this happens.
If the session is closed via Session::shutdown all threads currently blocking inside this function
will return Err(())
pub fn send(&self, buf: &[u8]) -> Result<usize>
Trait Implementations§
Source§impl AsyncRead for AsyncSession
impl AsyncRead for AsyncSession
Source§impl AsyncWrite for AsyncSession
impl AsyncWrite for AsyncSession
Source§fn poll_write(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, _cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize>>
buf into the object. Read moreSource§fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<()>>
Source§impl Clone for AsyncSession
impl Clone for AsyncSession
Source§fn clone(&self) -> AsyncSession
fn clone(&self) -> AsyncSession
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Deref for AsyncSession
impl Deref for AsyncSession
Auto Trait Implementations§
impl Freeze for AsyncSession
impl RefUnwindSafe for AsyncSession
impl Send for AsyncSession
impl Sync for AsyncSession
impl Unpin for AsyncSession
impl UnsafeUnpin for AsyncSession
impl UnwindSafe for AsyncSession
Blanket Implementations§
Source§impl<R> AsyncReadExt for R
impl<R> AsyncReadExt for R
Source§fn chain<R>(self, next: R) -> Chain<Self, R>
fn chain<R>(self, next: R) -> Chain<Self, R>
Source§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
buf in asynchronous
manner, returning a future type. Read moreSource§fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectored<'a, Self>where
Self: Unpin,
fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectored<'a, Self>where
Self: Unpin,
AsyncRead into bufs using vectored
IO operations. Read moreSource§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
buf,
returning an error if end of file (EOF) is hit sooner. Read moreSource§fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
AsyncRead. Read moreSource§fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToString<'a, Self>where
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToString<'a, Self>where
Self: Unpin,
AsyncRead. Read moreSource§impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
Source§fn flush(&mut self) -> Flush<'_, Self>where
Self: Unpin,
fn flush(&mut self) -> Flush<'_, Self>where
Self: Unpin,
AsyncWrite. Read moreSource§fn close(&mut self) -> Close<'_, Self>where
Self: Unpin,
fn close(&mut self) -> Close<'_, Self>where
Self: Unpin,
AsyncWrite.Source§fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self>where
Self: Unpin,
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self>where
Self: Unpin,
buf into the object. Read moreSource§fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectored<'a, Self>where
Self: Unpin,
fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectored<'a, Self>where
Self: Unpin,
bufs into the object using vectored
IO operations. Read more