pub struct Session { /* private fields */ }Expand description
Wrapper around a https://git.zx2c4.com/wintun/about/#wintun_session_handle
Implementations§
Source§impl Session
impl 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>
Source§impl Session
impl Session
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(())