Skip to main content

VsockDeviceConnectionManager

Struct VsockDeviceConnectionManager 

Source
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>

Source

pub fn new(driver: VirtIOSocketDevice<H, T>) -> Self

Construct a new connection manager wrapping the given low-level VirtIO socket driver.

Source

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.

Source

pub fn listen(&mut self, port: u32)

Allows incoming connections on the given port number.

Source

pub fn unlisten(&mut self, port: u32)

Stops allowing incoming connections on the given port number.

Source

pub fn send( &mut self, destination: VsockAddr, src_port: u32, buffer: &[u8], ) -> Result

Sends the buffer to the destination.

Source

pub fn poll(&mut self) -> Result<Option<VsockEvent>>

Polls the vsock device to receive data or other updates.

Source

pub fn recv( &mut self, peer: VsockAddr, src_port: u32, buffer: &mut [u8], ) -> Result<usize>

Reads data received from the given connection.

Source

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.

Source

pub fn update_credit(&mut self, peer: VsockAddr, src_port: u32) -> Result

Sends a credit update to the given peer.

Source

pub fn wait_for_event(&mut self) -> Result<VsockEvent>

Blocks until we get some event from the vsock device.

Source

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.

Source

pub fn force_close(&mut self, destination: VsockAddr, src_port: u32) -> Result

Forcibly closes the connection without waiting for the peer.

Trait Implementations§

Source§

impl<H: DeviceHal, T: DeviceTransport> VsockManager for VsockDeviceConnectionManager<H, T>

Source§

fn connect(&mut self, _destination: VsockAddr, _src_port: u32) -> Result

Sends a request to connect to the given destination on the driver side. Read more
Source§

fn send(&mut self, dest: VsockAddr, src_port: u32, buffer: &[u8]) -> Result

Sends the buffer to the destination.
Source§

fn update_credit(&mut self, peer: VsockAddr, src_port: u32) -> Result

Sends a credit update to the given peer.
Source§

fn force_close(&mut self, dest: VsockAddr, src_port: u32) -> Result

Forcibly closes the connection without waiting for the peer.
Source§

fn listen(&mut self, port: u32)

Allows incoming connections on the given port number.
Source§

fn poll(&mut self) -> Result<Option<VsockEvent>>

Polls the vsock device to receive data or other updates.
Source§

fn local_cid(&self) -> u64

Returns the local CID, i.e. the CID of the guest on the driver side and the CID of the host on the device side.
Source§

fn shutdown(&mut self, dest: 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. Read more
Source§

fn recv( &mut self, peer: VsockAddr, src_port: u32, buffer: &mut [u8], ) -> Result<usize>

Reads data received from the given connection.
Source§

unsafe fn ack_interrupt(_ptr: *mut Self) -> InterruptStatus

Acknowledges an interrupt using a pointer to the VsockManager impl Read more

Auto Trait Implementations§

§

impl<H, T> Freeze for VsockDeviceConnectionManager<H, T>
where T: Freeze,

§

impl<H, T> RefUnwindSafe for VsockDeviceConnectionManager<H, T>

§

impl<H, T> Send for VsockDeviceConnectionManager<H, T>
where T: Send,

§

impl<H, T> Sync for VsockDeviceConnectionManager<H, T>
where T: Sync,

§

impl<H, T> Unpin for VsockDeviceConnectionManager<H, T>
where T: Unpin, H: Unpin,

§

impl<H, T> UnsafeUnpin for VsockDeviceConnectionManager<H, T>
where T: UnsafeUnpin,

§

impl<H, T> UnwindSafe for VsockDeviceConnectionManager<H, T>
where T: UnwindSafe, H: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.