pub struct FrontendServer<S: Frontend> {
    pub(crate) sub_sock: Connection<BackendReq>,
    reply_ack_negotiated: bool,
    frontend: S,
}
Expand description

Handles requests from a vhost-user backend connection by dispatching them to [Frontend] methods.

Fields§

§sub_sock: Connection<BackendReq>§reply_ack_negotiated: bool§frontend: S

Implementations§

source§

impl<S: Frontend> FrontendServer<S>

source

pub fn with_stream(backend: S) -> Result<(Self, SafeDescriptor)>

Create a FrontendServer that uses a Unix stream internally.

The returned SafeDescriptor is the client side of the stream and should be sent to the backend using BackendClient::set_slave_request_fd().

source§

impl<S: Frontend> FrontendServer<S>

source

pub(crate) fn new(frontend: S, stream: SystemStream) -> Result<Self>

Create a server to handle requests from stream.

source

pub fn set_reply_ack_flag(&mut self, enable: bool)

Set the negotiation state of the VHOST_USER_PROTOCOL_F_REPLY_ACK protocol feature.

When the VHOST_USER_PROTOCOL_F_REPLY_ACK protocol feature has been negotiated, the “REPLY_ACK” flag will be set in the message header for every request message.

source

pub fn frontend_mut(&mut self) -> &mut S

Get the underlying frontend

source

pub fn handle_request(&mut self) -> Result<u64>

Process the next received request.

The caller needs to:

  • serialize calls to this function
  • decide what to do when errer happens
  • optional recover from failure
source

fn check_msg_size( &self, hdr: &VhostUserMsgHeader<BackendReq>, size: usize, expected: usize ) -> Result<()>

source

fn check_attached_files( &self, hdr: &VhostUserMsgHeader<BackendReq>, files: &[File] ) -> Result<()>

source

fn extract_msg_body<T: Sized + VhostUserMsgValidator>( &self, hdr: &VhostUserMsgHeader<BackendReq>, size: usize, buf: &[u8] ) -> Result<T>

source

fn new_reply_header<T: Sized>( &self, req: &VhostUserMsgHeader<BackendReq> ) -> Result<VhostUserMsgHeader<BackendReq>>

source

fn send_reply( &mut self, req: &VhostUserMsgHeader<BackendReq>, res: &Result<u64> ) -> Result<()>

Trait Implementations§

source§

impl<S: Frontend> AsRawDescriptor for FrontendServer<S>

source§

fn as_raw_descriptor(&self) -> RawDescriptor

Used for polling.

Auto Trait Implementations§

§

impl<S> !RefUnwindSafe for FrontendServer<S>

§

impl<S> Send for FrontendServer<S>where S: Send,

§

impl<S> !Sync for FrontendServer<S>

§

impl<S> Unpin for FrontendServer<S>where S: Unpin,

§

impl<S> UnwindSafe for FrontendServer<S>where S: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsRawDescriptors for Twhere T: AsRawDescriptor,

§

fn as_raw_descriptors(&self) -> Vec<i32, Global>

Returns the underlying raw descriptors. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.