objc2_virtualization/generated/
VZGraphicsDisplay.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::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_class!(
13    /// Class representing a graphics display in a virtual machine.
14    ///
15    /// VZGraphicsDisplay should not be instantiated directly.
16    ///
17    /// Graphics displays are first configured on a VZGraphicsDeviceConfiguration subclass.
18    /// When a VZVirtualMachine is created from the configuration, the displays
19    /// are available through the VZGraphicsDevice's `displays` property.
20    ///
21    ///
22    /// See: VZMacGraphicsDisplayConfiguration
23    ///
24    /// See: VZVirtioGraphicsScanoutConfiguration
25    ///
26    /// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzgraphicsdisplay?language=objc)
27    #[unsafe(super(NSObject))]
28    #[derive(Debug, PartialEq, Eq, Hash)]
29    pub struct VZGraphicsDisplay;
30);
31
32extern_conformance!(
33    unsafe impl NSObjectProtocol for VZGraphicsDisplay {}
34);
35
36impl VZGraphicsDisplay {
37    extern_methods!(
38        #[unsafe(method(new))]
39        #[unsafe(method_family = new)]
40        pub unsafe fn new() -> Retained<Self>;
41
42        #[unsafe(method(init))]
43        #[unsafe(method_family = init)]
44        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
45
46        #[cfg(feature = "objc2-core-foundation")]
47        /// The size of the display, in pixels.
48        #[unsafe(method(sizeInPixels))]
49        #[unsafe(method_family = none)]
50        pub unsafe fn sizeInPixels(&self) -> CGSize;
51
52        #[cfg(feature = "objc2-core-foundation")]
53        /// Resize this display.
54        ///
55        /// Parameter `sizeInPixels`: New display width and height in pixels.
56        ///
57        /// Parameter `error`: If not nil, assigned with an error describing why the new size is not valid.
58        ///
59        /// Returns: YES if the resize is successful, NO otherwise.
60        ///
61        /// If successful, the new size will be passed to the guest but the guest may or may
62        /// not respond to the new size. The guest not using the size does not return an error.
63        ///
64        /// Reconfiguration triggers a display state change which can be tracked by VZGraphicsDisplayObservers.
65        #[unsafe(method(reconfigureWithSizeInPixels:error:_))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn reconfigureWithSizeInPixels_error(
68            &self,
69            size_in_pixels: CGSize,
70        ) -> Result<(), Retained<NSError>>;
71
72        #[cfg(feature = "VZGraphicsDisplayConfiguration")]
73        /// Reconfigure this display.
74        ///
75        /// Parameter `configuration`: New display configuration.
76        ///
77        /// Parameter `error`: If not nil, assigned with an error describing why the new configuration is not valid.
78        ///
79        /// Returns: YES if the reconfiguration is successful, NO otherwise.
80        ///
81        /// The type of the configuration must match the corresponding type that caused this display to be created.
82        ///
83        /// If successful, the new configuration will be passed to the guest but the guest may or may
84        /// not respond to parts of the configuration. The guest not using the new configuration does not
85        /// return an error.
86        ///
87        /// Reconfiguration triggers a display state change which can be tracked by VZGraphicsDisplayObservers.
88        #[unsafe(method(reconfigureWithConfiguration:error:_))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn reconfigureWithConfiguration_error(
91            &self,
92            configuration: &VZGraphicsDisplayConfiguration,
93        ) -> Result<(), Retained<NSError>>;
94
95        /// Add an observer.
96        ///
97        /// Parameter `observer`: The new observer to be notified of display state changes.
98        #[unsafe(method(addObserver:))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn addObserver(&self, observer: &ProtocolObject<dyn VZGraphicsDisplayObserver>);
101
102        /// Remove an observer.
103        ///
104        /// Parameter `observer`: The observer to be removed.
105        #[unsafe(method(removeObserver:))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn removeObserver(
108            &self,
109            observer: &ProtocolObject<dyn VZGraphicsDisplayObserver>,
110        );
111    );
112}
113
114extern_protocol!(
115    /// VZGraphicsDisplayObserver observes a VZGraphicsDisplay for state changes.
116    ///
117    /// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzgraphicsdisplayobserver?language=objc)
118    pub unsafe trait VZGraphicsDisplayObserver: NSObjectProtocol {
119        /// A reconfiguration operation has begun.
120        ///
121        /// A configuration change, such as a resize, has been issued and new frames are expected with a new size or configuration.
122        /// This method will be invoked on the virtual machine's queue.
123        ///
124        /// Parameter `display`: The display whose state is changing.
125        #[optional]
126        #[unsafe(method(displayDidBeginReconfiguration:))]
127        #[unsafe(method_family = none)]
128        unsafe fn displayDidBeginReconfiguration(&self, display: &VZGraphicsDisplay);
129
130        /// A reconfiguration operation has ended.
131        ///
132        /// Frame updates have arrived at the most recently requested display size and configuration.
133        /// This method will be invoked on the virtual machine's queue.
134        ///
135        /// Parameter `display`: The display whose state is changing.
136        #[optional]
137        #[unsafe(method(displayDidEndReconfiguration:))]
138        #[unsafe(method_family = none)]
139        unsafe fn displayDidEndReconfiguration(&self, display: &VZGraphicsDisplay);
140    }
141);