Struct virtio_drivers::device::socket::VirtIOSocket
source · pub struct VirtIOSocket<H: Hal, T: Transport> { /* private fields */ }Expand description
Low-level driver for a VirtIO socket device.
You probably want to use VsockConnectionManager rather than
using this directly.
Implementations§
source§impl<H: Hal, T: Transport> VirtIOSocket<H, T>
impl<H: Hal, T: Transport> VirtIOSocket<H, T>
sourcepub fn connect(&mut self, connection_info: &ConnectionInfo) -> Result
pub fn connect(&mut self, connection_info: &ConnectionInfo) -> Result
Sends a request to connect to the given destination.
This returns as soon as the request is sent; you should wait until poll returns a
VsockEventType::Connected event indicating that the peer has accepted the connection
before sending data.
sourcepub fn accept(&mut self, connection_info: &ConnectionInfo) -> Result
pub fn accept(&mut self, connection_info: &ConnectionInfo) -> Result
Accepts the given connection from a peer.
sourcepub fn send(
&mut self,
buffer: &[u8],
connection_info: &mut ConnectionInfo
) -> Result
pub fn send( &mut self, buffer: &[u8], connection_info: &mut ConnectionInfo ) -> Result
Sends the buffer to the destination.
sourcepub fn credit_update(&mut self, connection_info: &ConnectionInfo) -> Result
pub fn credit_update(&mut self, connection_info: &ConnectionInfo) -> Result
Tells the peer how much buffer space we have to receive data.
sourcepub fn poll(
&mut self,
handler: impl FnOnce(VsockEvent, &[u8]) -> Result<Option<VsockEvent>>
) -> Result<Option<VsockEvent>>
pub fn poll( &mut self, handler: impl FnOnce(VsockEvent, &[u8]) -> Result<Option<VsockEvent>> ) -> Result<Option<VsockEvent>>
Polls the RX virtqueue for the next event, and calls the given handler function to handle it.
sourcepub fn shutdown(&mut self, connection_info: &ConnectionInfo) -> Result
pub fn shutdown(&mut self, connection_info: &ConnectionInfo) -> Result
Requests to shut down the connection cleanly.
This returns as soon as the request is sent; you should wait until poll returns a
VsockEventType::Disconnected event if you want to know that the peer has acknowledged the
shutdown.
sourcepub fn force_close(&mut self, connection_info: &ConnectionInfo) -> Result
pub fn force_close(&mut self, connection_info: &ConnectionInfo) -> Result
Forcibly closes the connection without waiting for the peer.