objc2_virtualization/generated/
VZUSBController.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// Class representing a USB controller in a virtual machine.
12    ///
13    /// VZUSBController should not be instantiated directly.
14    /// USB controllers are first configured on the VZVirtualMachineConfiguration through a subclass of VZUSBControllerConfiguration.
15    /// When a VZVirtualMachine is created from the configuration, the USB controllers are available through the VZVirtualMachine.usbControllers property.
16    /// The real type of VZUSBController corresponds to the type used by the configuration.
17    /// For example, a VZXHCIControllerConfiguration leads to a device of type VZXHCIController.
18    ///
19    /// See: VZUSBControllerConfiguration
20    ///
21    /// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzusbcontroller?language=objc)
22    #[unsafe(super(NSObject))]
23    #[derive(Debug, PartialEq, Eq, Hash)]
24    pub struct VZUSBController;
25);
26
27extern_conformance!(
28    unsafe impl NSObjectProtocol for VZUSBController {}
29);
30
31impl VZUSBController {
32    extern_methods!(
33        #[unsafe(method(new))]
34        #[unsafe(method_family = new)]
35        pub unsafe fn new() -> Retained<Self>;
36
37        #[unsafe(method(init))]
38        #[unsafe(method_family = init)]
39        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
40
41        #[cfg(all(feature = "VZUSBDevice", feature = "block2"))]
42        /// Attach a USB device.
43        ///
44        /// If the device is successfully attached to the controller, it will appear in the usbDevices property,
45        /// its usbController property will be set to point to the USB controller that it is attached to
46        /// and completion handler will return nil.
47        /// If the device was previously attached to this or another USB controller, attach function will fail
48        /// with the `VZErrorDeviceAlreadyAttached`. If the device cannot be initialized correctly, attach
49        /// function will fail with `VZErrorDeviceInitializationFailure`.
50        /// This method must be called on the virtual machine's queue.
51        ///
52        /// Parameter `device`: USB device to attach.
53        ///
54        /// Parameter `completionHandler`: Block called after the device has been attached or on error.
55        /// The error parameter passed to the block is nil if the attach was successful.
56        /// It will be also invoked on an virtual machine's queue.
57        ///
58        /// See: VZUSBDevice
59        #[unsafe(method(attachDevice:completionHandler:))]
60        #[unsafe(method_family = none)]
61        pub unsafe fn attachDevice_completionHandler(
62            &self,
63            device: &ProtocolObject<dyn VZUSBDevice>,
64            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
65        );
66
67        #[cfg(all(feature = "VZUSBDevice", feature = "block2"))]
68        /// Detach a USB device.
69        ///
70        /// If the device is successfully detached from the controller, it will disappear from the usbDevices property,
71        /// its usbController property will be set to nil and completion handler will return nil.
72        /// If the device wasn't attached to the controller at the time of calling detach method, it will fail
73        /// with the `VZErrorDeviceNotFound` error.
74        /// This method must be called on the virtual machine's queue.
75        ///
76        /// Parameter `device`: USB device to detach.
77        ///
78        /// Parameter `completionHandler`: Block called after the device has been detached or on error.
79        /// The error parameter passed to the block is nil if the detach was successful.
80        /// It will be also invoked on an virtual machine's queue.
81        ///
82        /// See: VZUSBDevice
83        #[unsafe(method(detachDevice:completionHandler:))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn detachDevice_completionHandler(
86            &self,
87            device: &ProtocolObject<dyn VZUSBDevice>,
88            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
89        );
90
91        #[cfg(feature = "VZUSBDevice")]
92        /// Return a list of USB devices attached to controller.
93        ///
94        /// If corresponding USB controller configuration included in VZVirtualMachineConfiguration contained  any USB devices,
95        /// those devices will appear here when virtual machine is started.
96        ///
97        /// See: VZUSBDevice
98        ///
99        /// See: VZUSBDeviceConfiguration
100        ///
101        /// See: VZUSBControllerConfiguration
102        ///
103        /// See: VZVirtualMachineConfiguration
104        #[unsafe(method(usbDevices))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn usbDevices(&self) -> Retained<NSArray<ProtocolObject<dyn VZUSBDevice>>>;
107    );
108}