pub struct VsockDeviceConnectionManager<H: DeviceHal, T: DeviceTransport>(/* private fields */);Expand description
A high level interface for VirtIO socket (vsock) devices.
Implementations§
Source§impl<H: DeviceHal, T: DeviceTransport> VsockDeviceConnectionManager<H, T>
impl<H: DeviceHal, T: DeviceTransport> VsockDeviceConnectionManager<H, T>
Sourcepub fn new(driver: VirtIOSocketDevice<H, T>) -> Self
pub fn new(driver: VirtIOSocketDevice<H, T>) -> Self
Construct a new connection manager wrapping the given low-level VirtIO socket driver.
Sourcepub fn new_with_capacity(
driver: VirtIOSocketDevice<H, T>,
per_connection_buffer_capacity: u32,
) -> Self
pub fn new_with_capacity( driver: VirtIOSocketDevice<H, T>, per_connection_buffer_capacity: u32, ) -> Self
Construct a new connection manager wrapping the given low-level VirtIO socket driver, with the given per-connection buffer capacity.
Sourcepub fn unlisten(&mut self, port: u32)
pub fn unlisten(&mut self, port: u32)
Stops allowing incoming connections on the given port number.
Sourcepub fn send(
&mut self,
destination: VsockAddr,
src_port: u32,
buffer: &[u8],
) -> Result
pub fn send( &mut self, destination: VsockAddr, src_port: u32, buffer: &[u8], ) -> Result
Sends the buffer to the destination.
Sourcepub fn poll(&mut self) -> Result<Option<VsockEvent>>
pub fn poll(&mut self) -> Result<Option<VsockEvent>>
Polls the vsock device to receive data or other updates.
Sourcepub fn recv(
&mut self,
peer: VsockAddr,
src_port: u32,
buffer: &mut [u8],
) -> Result<usize>
pub fn recv( &mut self, peer: VsockAddr, src_port: u32, buffer: &mut [u8], ) -> Result<usize>
Reads data received from the given connection.
Sourcepub fn recv_buffer_available_bytes(
&mut self,
peer: VsockAddr,
src_port: u32,
) -> Result<usize>
pub fn recv_buffer_available_bytes( &mut self, peer: VsockAddr, src_port: u32, ) -> Result<usize>
Returns the number of bytes in the receive buffer available to be read by recv.
When the available bytes is 0, it indicates that the receive buffer is empty and does not contain any data.
Sourcepub fn update_credit(&mut self, peer: VsockAddr, src_port: u32) -> Result
pub fn update_credit(&mut self, peer: VsockAddr, src_port: u32) -> Result
Sends a credit update to the given peer.
Sourcepub fn wait_for_event(&mut self) -> Result<VsockEvent>
pub fn wait_for_event(&mut self) -> Result<VsockEvent>
Blocks until we get some event from the vsock device.
Sourcepub fn shutdown(&mut self, destination: VsockAddr, src_port: u32) -> Result
pub fn shutdown(&mut self, destination: VsockAddr, src_port: u32) -> Result
Requests to shut down the connection cleanly, telling the peer that we won’t send or receive any more data.
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, destination: VsockAddr, src_port: u32) -> Result
pub fn force_close(&mut self, destination: VsockAddr, src_port: u32) -> Result
Forcibly closes the connection without waiting for the peer.