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::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// Class representing a graphics display in a virtual machine.
    ///
    /// VZGraphicsDisplay should not be instantiated directly.
    ///
    /// Graphics displays are first configured on a VZGraphicsDeviceConfiguration subclass.
    /// When a VZVirtualMachine is created from the configuration, the displays
    /// are available through the VZGraphicsDevice's `displays` property.
    ///
    ///
    /// See: VZMacGraphicsDisplayConfiguration
    ///
    /// See: VZVirtioGraphicsScanoutConfiguration
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzgraphicsdisplay?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct VZGraphicsDisplay;
);

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

impl VZGraphicsDisplay {
    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(feature = "objc2-core-foundation")]
        /// The size of the display, in pixels.
        #[unsafe(method(sizeInPixels))]
        #[unsafe(method_family = none)]
        pub unsafe fn sizeInPixels(&self) -> CGSize;

        #[cfg(feature = "objc2-core-foundation")]
        /// Resize this display.
        ///
        /// Parameter `sizeInPixels`: New display width and height in pixels.
        ///
        /// Parameter `error`: If not nil, assigned with an error describing why the new size is not valid.
        ///
        /// Returns: YES if the resize is successful, NO otherwise.
        ///
        /// If successful, the new size will be passed to the guest but the guest may or may
        /// not respond to the new size. The guest not using the size does not return an error.
        ///
        /// Reconfiguration triggers a display state change which can be tracked by VZGraphicsDisplayObservers.
        #[unsafe(method(reconfigureWithSizeInPixels:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn reconfigureWithSizeInPixels_error(
            &self,
            size_in_pixels: CGSize,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(feature = "VZGraphicsDisplayConfiguration")]
        /// Reconfigure this display.
        ///
        /// Parameter `configuration`: New display configuration.
        ///
        /// Parameter `error`: If not nil, assigned with an error describing why the new configuration is not valid.
        ///
        /// Returns: YES if the reconfiguration is successful, NO otherwise.
        ///
        /// The type of the configuration must match the corresponding type that caused this display to be created.
        ///
        /// If successful, the new configuration will be passed to the guest but the guest may or may
        /// not respond to parts of the configuration. The guest not using the new configuration does not
        /// return an error.
        ///
        /// Reconfiguration triggers a display state change which can be tracked by VZGraphicsDisplayObservers.
        #[unsafe(method(reconfigureWithConfiguration:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn reconfigureWithConfiguration_error(
            &self,
            configuration: &VZGraphicsDisplayConfiguration,
        ) -> Result<(), Retained<NSError>>;

        /// Add an observer.
        ///
        /// Parameter `observer`: The new observer to be notified of display state changes.
        #[unsafe(method(addObserver:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addObserver(&self, observer: &ProtocolObject<dyn VZGraphicsDisplayObserver>);

        /// Remove an observer.
        ///
        /// Parameter `observer`: The observer to be removed.
        #[unsafe(method(removeObserver:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeObserver(
            &self,
            observer: &ProtocolObject<dyn VZGraphicsDisplayObserver>,
        );
    );
}

extern_protocol!(
    /// VZGraphicsDisplayObserver observes a VZGraphicsDisplay for state changes.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzgraphicsdisplayobserver?language=objc)
    pub unsafe trait VZGraphicsDisplayObserver: NSObjectProtocol {
        /// A reconfiguration operation has begun.
        ///
        /// A configuration change, such as a resize, has been issued and new frames are expected with a new size or configuration.
        /// This method will be invoked on the virtual machine's queue.
        ///
        /// Parameter `display`: The display whose state is changing.
        #[optional]
        #[unsafe(method(displayDidBeginReconfiguration:))]
        #[unsafe(method_family = none)]
        unsafe fn displayDidBeginReconfiguration(&self, display: &VZGraphicsDisplay);

        /// A reconfiguration operation has ended.
        ///
        /// Frame updates have arrived at the most recently requested display size and configuration.
        /// This method will be invoked on the virtual machine's queue.
        ///
        /// Parameter `display`: The display whose state is changing.
        #[optional]
        #[unsafe(method(displayDidEndReconfiguration:))]
        #[unsafe(method_family = none)]
        unsafe fn displayDidEndReconfiguration(&self, display: &VZGraphicsDisplay);
    }
);