objc2-virtualization 0.3.2

Bindings to the Virtualization framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// Class representing a USB controller in a virtual machine.
    ///
    /// VZUSBController should not be instantiated directly.
    /// USB controllers are first configured on the VZVirtualMachineConfiguration through a subclass of VZUSBControllerConfiguration.
    /// When a VZVirtualMachine is created from the configuration, the USB controllers are available through the VZVirtualMachine.usbControllers property.
    /// The real type of VZUSBController corresponds to the type used by the configuration.
    /// For example, a VZXHCIControllerConfiguration leads to a device of type VZXHCIController.
    ///
    /// See: VZUSBControllerConfiguration
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzusbcontroller?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct VZUSBController;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for VZUSBController {}
);

impl VZUSBController {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(all(feature = "VZUSBDevice", feature = "block2"))]
        /// Attach a USB device.
        ///
        /// If the device is successfully attached to the controller, it will appear in the usbDevices property,
        /// its usbController property will be set to point to the USB controller that it is attached to
        /// and completion handler will return nil.
        /// If the device was previously attached to this or another USB controller, attach function will fail
        /// with the `VZErrorDeviceAlreadyAttached`. If the device cannot be initialized correctly, attach
        /// function will fail with `VZErrorDeviceInitializationFailure`.
        /// This method must be called on the virtual machine's queue.
        ///
        /// Parameter `device`: USB device to attach.
        ///
        /// Parameter `completionHandler`: Block called after the device has been attached or on error.
        /// The error parameter passed to the block is nil if the attach was successful.
        /// It will be also invoked on an virtual machine's queue.
        ///
        /// See: VZUSBDevice
        #[unsafe(method(attachDevice:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn attachDevice_completionHandler(
            &self,
            device: &ProtocolObject<dyn VZUSBDevice>,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(all(feature = "VZUSBDevice", feature = "block2"))]
        /// Detach a USB device.
        ///
        /// If the device is successfully detached from the controller, it will disappear from the usbDevices property,
        /// its usbController property will be set to nil and completion handler will return nil.
        /// If the device wasn't attached to the controller at the time of calling detach method, it will fail
        /// with the `VZErrorDeviceNotFound` error.
        /// This method must be called on the virtual machine's queue.
        ///
        /// Parameter `device`: USB device to detach.
        ///
        /// Parameter `completionHandler`: Block called after the device has been detached or on error.
        /// The error parameter passed to the block is nil if the detach was successful.
        /// It will be also invoked on an virtual machine's queue.
        ///
        /// See: VZUSBDevice
        #[unsafe(method(detachDevice:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn detachDevice_completionHandler(
            &self,
            device: &ProtocolObject<dyn VZUSBDevice>,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "VZUSBDevice")]
        /// Return a list of USB devices attached to controller.
        ///
        /// If corresponding USB controller configuration included in VZVirtualMachineConfiguration contained  any USB devices,
        /// those devices will appear here when virtual machine is started.
        ///
        /// See: VZUSBDevice
        ///
        /// See: VZUSBDeviceConfiguration
        ///
        /// See: VZUSBControllerConfiguration
        ///
        /// See: VZVirtualMachineConfiguration
        #[unsafe(method(usbDevices))]
        #[unsafe(method_family = none)]
        pub unsafe fn usbDevices(&self) -> Retained<NSArray<ProtocolObject<dyn VZUSBDevice>>>;
    );
}