objc2_virtualization/generated/VZMacOSInstaller.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 /// VZMacOSInstaller is used to install macOS on the specified virtual machine.
12 ///
13 /// A VZMacOSInstaller object must be initialized with a VZVirtualMachine and a file URL referring to a macOS restore image.
14 /// The following code example shows how VZMacOSInstaller is used.
15 ///
16 /// <pre>
17 ///
18 /// ```text
19 ///
20 /// // VZMacOSInstaller must be called with a URL corresponding to a local file. We need a place to store the restore image we download.
21 /// NSURL *localRestoreImageURL = ...;
22 ///
23 /// // Load the latest restore image.
24 /// [VZMacOSRestoreImage fetchLatestSupportedWithCompletionHandler:^(VZMacOSRestoreImage *restoreImage, NSError *error) {
25 /// if (error) {
26 /// // Handle the error.
27 /// abort();
28 /// }
29 ///
30 /// // VZMacOSInstaller must be called with a URL corresponding to a local file. Since restoreImage came from
31 /// // fetchLatestSupportedWithCompletionHandler, its URL property refers to a restore image on the network.
32 /// // Download the restore image to the local filesystem.
33 /// [[NSURLSession sharedSession] downloadTaskWithURL:restoreImage.URL completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
34 /// if (error) {
35 /// // Handle the error.
36 /// abort();
37 /// }
38 /// if (![[NSFileManager defaultManager] moveItemAtURL:location toURL:localRestoreImageURL error:&error]) {
39 /// // Handle the error.
40 /// abort();
41 /// }
42 /// dispatch_async(dispatch_get_main_queue(), ^{
43 /// // Since this restore image came from -[VZMacOSRestoreImage fetchLatestSupportedWithCompletionHandler:], mostFeaturefulSupportedConfiguration should not be nil.
44 /// VZMacOSConfigurationRequirements *configurationRequirements = restoreImage.mostFeaturefulSupportedConfiguration;
45 ///
46 /// // Construct a VZVirtualMachineConfiguration that satisfies the configuration requirements.
47 /// VZVirtualMachineConfiguration *configuration = [[VZVirtualMachineConfiguration alloc] init];
48 /// configuration.bootLoader = [[VZMacOSBootLoader alloc] init];
49 /// configuration.platform = [[VZMacPlatformConfiguration alloc] init];
50 ///
51 /// // The following are minimum values; you can use larger values if desired.
52 /// configuration.CPUCount = configurationRequirements.minimumSupportedCPUCount;
53 /// configuration.memorySize = configurationRequirements.minimumSupportedMemorySize;
54 ///
55 /// // Set other configuration properties as necessary.
56 /// // ...
57 ///
58 /// assert([configuration validateWithError:nil]);
59 ///
60 /// VZVirtualMachine *virtualMachine = [[VZVirtualMachine alloc] initWithConfiguration:configuration];
61 /// VZMacOSInstaller *installer = [[VZMacOSInstaller alloc] initWithVirtualMachine:virtualMachine restoreImageURL:localRestoreImageURL];
62 /// [installer installWithCompletionHandler:^(NSError *error) {
63 /// if (error) {
64 /// // Handle the error.
65 /// abort();
66 /// } else {
67 /// // Installation was successful.
68 /// }
69 /// }];
70 ///
71 /// // Observe progress using installer.progress object.
72 /// });
73 /// }];
74 /// }];
75 ///
76 /// ```
77 ///
78 /// </pre>
79 ///
80 /// See also: VZVirtualMachine
81 ///
82 /// See also: VZMacOSRestoreImage
83 ///
84 /// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzmacosinstaller?language=objc)
85 #[unsafe(super(NSObject))]
86 #[derive(Debug, PartialEq, Eq, Hash)]
87 pub struct VZMacOSInstaller;
88);
89
90extern_conformance!(
91 unsafe impl NSObjectProtocol for VZMacOSInstaller {}
92);
93
94impl VZMacOSInstaller {
95 extern_methods!(
96 #[unsafe(method(new))]
97 #[unsafe(method_family = new)]
98 pub unsafe fn new() -> Retained<Self>;
99
100 #[unsafe(method(init))]
101 #[unsafe(method_family = init)]
102 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
103
104 #[cfg(feature = "VZVirtualMachine")]
105 /// Initialize a VZMacOSInstaller object.
106 ///
107 /// Parameter `virtualMachine`: The virtual machine that the operating system will be installed onto.
108 ///
109 /// Parameter `restoreImageFileURL`: A file URL indicating the macOS restore image to install.
110 ///
111 /// The virtual machine platform must be macOS and the restore image URL must be a file URL referring to a file on disk or an exception will be raised.
112 /// This method must be called on the virtual machine's queue.
113 #[unsafe(method(initWithVirtualMachine:restoreImageURL:))]
114 #[unsafe(method_family = init)]
115 pub unsafe fn initWithVirtualMachine_restoreImageURL(
116 this: Allocated<Self>,
117 virtual_machine: &VZVirtualMachine,
118 restore_image_file_url: &NSURL,
119 ) -> Retained<Self>;
120
121 #[cfg(feature = "block2")]
122 /// Start installing macOS.
123 ///
124 /// Parameter `completionHandler`: Block called after installation has successfully completed or has failed.
125 /// The error parameter passed to the block is nil if installation was successful. The block will be invoked on the virtual machine's queue.
126 ///
127 /// This method starts the installation process. The virtual machine must be in a stopped state. During the installation operation, pausing or stopping
128 /// the virtual machine will result in undefined behavior.
129 /// If installation is started on the same VZMacOSInstaller object more than once, an exception will be raised.
130 /// This method must be called on the virtual machine's queue.
131 #[unsafe(method(installWithCompletionHandler:))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn installWithCompletionHandler(
134 &self,
135 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
136 );
137
138 /// An NSProgress object that can be used to observe or cancel installation.
139 ///
140 /// If the progress object is cancelled before installation is started, an exception will be raised.
141 #[unsafe(method(progress))]
142 #[unsafe(method_family = none)]
143 pub unsafe fn progress(&self) -> Retained<NSProgress>;
144
145 #[cfg(feature = "VZVirtualMachine")]
146 /// The virtual machine that this installer was initialized with.
147 #[unsafe(method(virtualMachine))]
148 #[unsafe(method_family = none)]
149 pub unsafe fn virtualMachine(&self) -> Retained<VZVirtualMachine>;
150
151 /// The restore image URL that this installer was initialized with.
152 #[unsafe(method(restoreImageURL))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn restoreImageURL(&self) -> Retained<NSURL>;
155 );
156}