Struct vmm_vhost::connection::Connection  
source · pub struct Connection<R: Req>(pub(crate) PlatformConnection, pub(crate) PhantomData<R>, pub(crate) PhantomData<Cell<()>>);Expand description
A vhost-user connection at a low abstraction level. Provides methods for sending and receiving vhost-user message headers and bodies.
Builds on top of PlatformConnection, which provides methods for sending and receiving raw
bytes and file descriptors (a thin cross-platform abstraction for unix domain sockets).
Tuple Fields§
§0: PlatformConnection§1: PhantomData<R>§2: PhantomData<Cell<()>>Implementations§
source§impl<R: Req> Connection<R>
 
impl<R: Req> Connection<R>
sourcepub fn send_header_only_message(
    &self,
    hdr: &VhostUserMsgHeader<R>,
    fds: Option<&[RawDescriptor]>,
) -> Result<()>
 
pub fn send_header_only_message( &self, hdr: &VhostUserMsgHeader<R>, fds: Option<&[RawDescriptor]>, ) -> Result<()>
Sends a header-only message with optional attached file descriptors.
sourcepub fn send_message<T: IntoBytes + Immutable>(
    &self,
    hdr: &VhostUserMsgHeader<R>,
    body: &T,
    fds: Option<&[RawDescriptor]>,
) -> Result<()>
 
pub fn send_message<T: IntoBytes + Immutable>( &self, hdr: &VhostUserMsgHeader<R>, body: &T, fds: Option<&[RawDescriptor]>, ) -> Result<()>
Send a message with header and body. Optional file descriptors may be attached to the message.
sourcepub fn send_message_with_payload<T: IntoBytes + Immutable>(
    &self,
    hdr: &VhostUserMsgHeader<R>,
    body: &T,
    payload: &[u8],
    fds: Option<&[RawDescriptor]>,
) -> Result<()>
 
pub fn send_message_with_payload<T: IntoBytes + Immutable>( &self, hdr: &VhostUserMsgHeader<R>, body: &T, payload: &[u8], fds: Option<&[RawDescriptor]>, ) -> Result<()>
Send a message with header and body. payload is appended to the end of the body. Optional
file descriptors may also be attached to the message.
sourcefn recv_into_bufs_all(&self, bufs: &mut [&mut [u8]]) -> Result<Vec<File>>
 
fn recv_into_bufs_all(&self, bufs: &mut [&mut [u8]]) -> Result<Vec<File>>
Reads all bytes into the given scatter/gather vectors with optional attached files. Will loop until all data has been transfered and errors if EOF is reached before then.
§Return:
- 
- received fds on success
 
 - 
Disconnect- client is closed
 
§TODO
This function takes a slice of &mut [u8] instead of IoSliceMut because the internal
cursor needs to be moved by advance_slices_mut().
Once IoSliceMut::advance_slices() becomes stable, this should be updated.
https://github.com/rust-lang/rust/issues/62726.
sourcepub fn recv_header(&self) -> Result<(VhostUserMsgHeader<R>, Vec<File>)>
 
pub fn recv_header(&self) -> Result<(VhostUserMsgHeader<R>, Vec<File>)>
Receive message header
Note, only the first MAX_ATTACHED_FD_ENTRIES file descriptors will be accepted and all other file descriptor will be discard silently.
sourcepub fn recv_body_bytes(
    &self,
    hdr: &VhostUserMsgHeader<R>,
) -> Result<(Vec<u8>, Vec<File>)>
 
pub fn recv_body_bytes( &self, hdr: &VhostUserMsgHeader<R>, ) -> Result<(Vec<u8>, Vec<File>)>
Receive the body following the header hdr.
sourcepub fn recv_message<T: IntoBytes + FromBytes>(
    &self,
) -> Result<(VhostUserMsgHeader<R>, T, Vec<File>)>
 
pub fn recv_message<T: IntoBytes + FromBytes>( &self, ) -> Result<(VhostUserMsgHeader<R>, T, Vec<File>)>
Receive a message header and body.
Note, only the first MAX_ATTACHED_FD_ENTRIES file descriptors will be accepted and all other file descriptor will be discard silently.
sourcepub fn recv_message_with_payload<T: IntoBytes + FromBytes>(
    &self,
) -> Result<(VhostUserMsgHeader<R>, T, Vec<u8>, Vec<File>, Vec<File>)>
 
pub fn recv_message_with_payload<T: IntoBytes + FromBytes>( &self, ) -> Result<(VhostUserMsgHeader<R>, T, Vec<u8>, Vec<File>, Vec<File>)>
Receive a message header and body, where the body includes a variable length payload at the end.
Note, only the first MAX_ATTACHED_FD_ENTRIES file descriptors will be accepted and all other file descriptor will be discard silently.
source§impl<R: Req> Connection<R>
 
impl<R: Req> Connection<R>
sourcepub fn pair() -> Result<(Self, Self)>
 
pub fn pair() -> Result<(Self, Self)>
Create a pair of unnamed vhost-user connections connected to each other.