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