pub struct Worker {
    cmd_queue: Queue,
    event_queue: Queue,
    desc_map: AsyncCmdDescMap,
}Expand description
Worker that takes care of running the virtio video device.
Fields§
§cmd_queue: QueueVirtIO queue for Command queue
event_queue: QueueVirtIO queue for Event queue
desc_map: AsyncCmdDescMapStores descriptor chains in which responses for asynchronous commands will be written
Implementations§
source§impl Worker
 
impl Worker
pub fn new(cmd_queue: Queue, event_queue: Queue) -> Self
sourcefn write_responses(
    &mut self,
    responses: &mut VecDeque<(DescriptorChain, CmdResponse)>,
) -> Result<(), Error>
 
fn write_responses( &mut self, responses: &mut VecDeque<(DescriptorChain, CmdResponse)>, ) -> Result<(), Error>
Writes responses into the command queue.
sourcefn write_event(&mut self, event: VideoEvt) -> Result<(), Error>
 
fn write_event(&mut self, event: VideoEvt) -> Result<(), Error>
Writes a VideoEvt into the event queue.
sourcefn write_event_responses(
    &mut self,
    event_responses: Vec<VideoEvtResponseType>,
    stream_id: u32,
) -> Result<(), Error>
 
fn write_event_responses( &mut self, event_responses: Vec<VideoEvtResponseType>, stream_id: u32, ) -> Result<(), Error>
Writes the event_responses into the command queue or the event queue according to
each response’s type.
§Arguments
event_responses- Responses to writestream_id- Stream session ID of the responses
sourcefn handle_command_desc(
    &mut self,
    device: &mut dyn Device,
    wait_ctx: &WaitContext<Token>,
    desc: DescriptorChain,
) -> Result<VecDeque<(DescriptorChain, CmdResponse)>, Error>
 
fn handle_command_desc( &mut self, device: &mut dyn Device, wait_ctx: &WaitContext<Token>, desc: DescriptorChain, ) -> Result<VecDeque<(DescriptorChain, CmdResponse)>, Error>
Handles a DescriptorChain value sent via the command queue and returns a VecDeque
of WritableResp to be sent to the guest.
§Arguments
device- Instance of backend devicewait_ctx-devicemay register a newToken::Eventfor a new stream session towait_ctxdesc-DescriptorChainto handle
sourcefn handle_command_queue(
    &mut self,
    device: &mut dyn Device,
    wait_ctx: &WaitContext<Token>,
) -> Result<(), Error>
 
fn handle_command_queue( &mut self, device: &mut dyn Device, wait_ctx: &WaitContext<Token>, ) -> Result<(), Error>
Handles each command in the command queue.
§Arguments
device- Instance of backend devicewait_ctx-devicemay register a newToken::Eventfor a new stream session towait_ctx
sourcefn handle_event(
    &mut self,
    device: &mut dyn Device,
    stream_id: u32,
    wait_ctx: &WaitContext<Token>,
) -> Result<(), Error>
 
fn handle_event( &mut self, device: &mut dyn Device, stream_id: u32, wait_ctx: &WaitContext<Token>, ) -> Result<(), Error>
Handles an event notified via an event.
§Arguments
device- Instance of backend devicestream_id- Stream session ID of the eventwait_ctx-devicemay register a newToken::Bufferfor a new stream session towait_ctx
sourcefn handle_buffer_barrier(
    &mut self,
    device: &mut dyn Device,
    stream_id: u32,
    wait_ctx: &WaitContext<Token>,
) -> Result<(), Error>
 
fn handle_buffer_barrier( &mut self, device: &mut dyn Device, stream_id: u32, wait_ctx: &WaitContext<Token>, ) -> Result<(), Error>
Handles a completed buffer barrier.
§Arguments
device- Instance of backend devicestream_id- Stream session ID of the eventwait_ctx-devicemay deregister the completedToken::BufferBarrierfromwait_ctx.
sourcepub fn run(
    &mut self,
    device: Box<dyn Device>,
    kill_evt: &Event,
) -> Result<(), Error>
 
pub fn run( &mut self, device: Box<dyn Device>, kill_evt: &Event, ) -> Result<(), Error>
Runs the video device virtio queues in a blocking way.
§Arguments
device- Instance of backend devicekill_evt-Eventnotified to makerunstop and return
sourcepub async fn run_async(
    self,
    device: Box<dyn Device>,
    ex: Executor,
    cmd_evt: Event,
    event_evt: Event,
) -> Result<(), Error>
 
pub async fn run_async( self, device: Box<dyn Device>, ex: Executor, cmd_evt: Event, event_evt: Event, ) -> Result<(), Error>
Runs the video device virtio queues asynchronously.
§Arguments
device- Instance of backend deviceex- Instance ofExecutorof asynchronous operationscmd_evt- Driver-to-device kick event for the command queueevent_evt- Driver-to-device kick event for the event queue
Auto Trait Implementations§
impl Freeze for Worker
impl !RefUnwindSafe for Worker
impl Send for Worker
impl Sync for Worker
impl Unpin for Worker
impl !UnwindSafe for Worker
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
    T: Any,
 
impl<T> Downcast for Twhere
    T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
 
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert 
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
 
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert 
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
 
fn as_any(&self) -> &(dyn Any + 'static)
Convert 
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
 
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert 
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.