vmbus_channel/
resources.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

//! Resource definitions related to vmbus.

use crate::channel::VmbusDevice;
use vm_resource::CanResolveTo;
use vm_resource::kind::VmbusDeviceHandleKind;
use vmcore::vm_task::VmTaskDriverSource;

impl CanResolveTo<ResolvedVmbusDevice> for VmbusDeviceHandleKind {
    type Input<'a> = ResolveVmbusDeviceHandleParams<'a>;
}

/// Resolve resource input parameters for vmbus device handles.
pub struct ResolveVmbusDeviceHandleParams<'a> {
    /// The driver source to use for spawning tasks and IO.
    pub driver_source: &'a VmTaskDriverSource,
}

/// A resolved vmbus device.
pub struct ResolvedVmbusDevice(pub Box<dyn VmbusDevice>);

impl<T: 'static + VmbusDevice> From<T> for ResolvedVmbusDevice {
    fn from(value: T) -> Self {
        Self(Box::new(value))
    }
}