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 crate::*;

extern_protocol!(
    /// Delegate object for VZVirtioConsoleDevice.
    ///
    /// A class conforming to the VZVirtioConsoleDeviceDelegate protocol can provide methods that notify when a console port is opened or closed in the virtual machine.
    ///
    /// See: VZVirtioConsoleDevice
    ///
    /// See: VZVirtioConsolePort
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzvirtioconsoledevicedelegate?language=objc)
    pub unsafe trait VZVirtioConsoleDeviceDelegate: NSObjectProtocol {
        #[cfg(all(feature = "VZConsoleDevice", feature = "VZVirtioConsolePort"))]
        /// Invoked when a guest process has opened a Virtio console port.
        ///
        /// Parameter `consoleDevice`: The console port's console device.
        ///
        /// Parameter `consolePort`: The console port that has been opened.
        ///
        /// Extra care should be taken to ensure that any pending data from the VZVirtioConsolePort attachment has been processed or flushed before communicating with a new virtual machine process.
        #[optional]
        #[unsafe(method(consoleDevice:didOpenPort:))]
        #[unsafe(method_family = none)]
        unsafe fn consoleDevice_didOpenPort(
            &self,
            console_device: &VZVirtioConsoleDevice,
            console_port: &VZVirtioConsolePort,
        );

        #[cfg(all(feature = "VZConsoleDevice", feature = "VZVirtioConsolePort"))]
        /// Invoked when a guest process has closed a Virtio console port.
        ///
        /// Parameter `consoleDevice`: The console port's console device.
        ///
        /// Parameter `consolePort`: The console port that has been closed.
        ///
        /// It is recommended to finish processing or flushing any remaining data from the VZVirtioConsolePort attachment after a port has been closed.
        #[optional]
        #[unsafe(method(consoleDevice:didClosePort:))]
        #[unsafe(method_family = none)]
        unsafe fn consoleDevice_didClosePort(
            &self,
            console_device: &VZVirtioConsoleDevice,
            console_port: &VZVirtioConsolePort,
        );
    }
);

extern_class!(
    /// Class representing a Virtio console device in a virtual machine.
    ///
    /// VZVirtioConsoleDevice should not be instantiated directly.
    ///
    /// See: VZConsoleDeviceConfiguration
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzvirtioconsoledevice?language=objc)
    #[unsafe(super(VZConsoleDevice, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "VZConsoleDevice")]
    pub struct VZVirtioConsoleDevice;
);

#[cfg(feature = "VZConsoleDevice")]
extern_conformance!(
    unsafe impl NSObjectProtocol for VZVirtioConsoleDevice {}
);

#[cfg(feature = "VZConsoleDevice")]
impl VZVirtioConsoleDevice {
    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>;

        /// Pointer to a delegate object for the console device.
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn VZVirtioConsoleDeviceDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn VZVirtioConsoleDeviceDelegate>>,
        );

        #[cfg(feature = "VZVirtioConsolePortArray")]
        /// The console ports currently being used by this console device.
        #[unsafe(method(ports))]
        #[unsafe(method_family = none)]
        pub unsafe fn ports(&self) -> Retained<VZVirtioConsolePortArray>;
    );
}