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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
/// Whether the host caches disk image data.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzdiskimagecachingmode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct VZDiskImageCachingMode(pub NSInteger);
impl VZDiskImageCachingMode {
#[doc(alias = "VZDiskImageCachingModeAutomatic")]
pub const Automatic: Self = Self(0);
#[doc(alias = "VZDiskImageCachingModeUncached")]
pub const Uncached: Self = Self(1);
#[doc(alias = "VZDiskImageCachingModeCached")]
pub const Cached: Self = Self(2);
}
unsafe impl Encode for VZDiskImageCachingMode {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for VZDiskImageCachingMode {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzdiskimagesynchronizationmode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct VZDiskImageSynchronizationMode(pub NSInteger);
impl VZDiskImageSynchronizationMode {
/// The data is synchronized to the permanent storage holding the disk image.
/// No synchronized data is lost on panic or loss of power.
#[doc(alias = "VZDiskImageSynchronizationModeFull")]
pub const Full: Self = Self(1);
/// Synchronize the data to the drive.
///
/// This mode synchronizes the data with the drive, but does not ensure the data is moved from the disk's internal cache
/// to permanent storage.
///
/// This is a best-effort mode with the same guarantees as the fsync() system call.
#[doc(alias = "VZDiskImageSynchronizationModeFsync")]
pub const Fsync: Self = Self(2);
/// Do not synchronize the data with the permanent storage.
/// This option does not guarantee data integrity if any error condition occurs such as disk full on the host,
/// panic, power loss, etc.
///
/// This mode is useful when a virtual machine is only run once to perform a task to completion or failure.
/// In that case, the disk image cannot safely be reused on failure.
///
/// Using this mode may result in improved performance since no synchronization with the underlying storage is necessary.
#[doc(alias = "VZDiskImageSynchronizationModeNone")]
pub const None: Self = Self(3);
}
unsafe impl Encode for VZDiskImageSynchronizationMode {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for VZDiskImageSynchronizationMode {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// Storage device attachment using a disk image to implement the storage.
///
/// This storage device attachment uses a disk image on the host file system as the drive of the storage device.
///
/// Only RAW data disk images are supported.
///
/// An empty RAW disk image can be created with `FileDescriptor.resize(to:retryOnInterrupt:)` method in Swift,
/// the `ftruncate()` function in Swift or Objective-C, or the `truncate` command on the command line.
/// The size of the file must be a multiple of 512 bytes, the block size.
///
/// See: VZNVMExpressControllerDeviceConfiguration
///
/// See: VZUSBMassStorageDeviceConfiguration
///
/// See: VZVirtioBlockDeviceConfiguration
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzdiskimagestoragedeviceattachment?language=objc)
#[unsafe(super(VZStorageDeviceAttachment, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "VZStorageDeviceAttachment")]
pub struct VZDiskImageStorageDeviceAttachment;
);
#[cfg(feature = "VZStorageDeviceAttachment")]
extern_conformance!(
unsafe impl NSObjectProtocol for VZDiskImageStorageDeviceAttachment {}
);
#[cfg(feature = "VZStorageDeviceAttachment")]
impl VZDiskImageStorageDeviceAttachment {
extern_methods!(
/// Initialize the attachment from a local file url.
///
/// Parameter `url`: Local file URL to the disk image in RAW format.
///
/// Parameter `readOnly`: If YES, the device attachment is read-only, otherwise the device can write data to the disk image.
///
/// Parameter `error`: If not nil, assigned with the error if the initialization failed.
///
/// Returns: A newly initialized VZDiskImageStorageDeviceAttachment. If an error was encountered returns
/// `nil,`and
/// `error`contains the error.
#[unsafe(method(initWithURL:readOnly:error:_))]
#[unsafe(method_family = init)]
pub unsafe fn initWithURL_readOnly_error(
this: Allocated<Self>,
url: &NSURL,
read_only: bool,
) -> Result<Retained<Self>, Retained<NSError>>;
/// Initialize the attachment from a local file url.
///
/// Parameter `url`: Local file URL to the disk image in RAW format.
///
/// Parameter `readOnly`: If YES, the device attachment is read-only, otherwise the device can write data to the disk image.
///
/// Parameter `cachingMode`: Whether host data caching is enabled for the disk image.
///
/// Parameter `synchronizationMode`: How the disk image synchronizes with the underlying storage when the guest operating system flushes data.
///
/// Parameter `error`: If not nil, assigned with the error if the initialization failed.
///
/// Returns: A newly initialized VZDiskImageStorageDeviceAttachment. If an error was encountered returns
/// `nil,`and
/// `error`contains the error.
#[unsafe(method(initWithURL:readOnly:cachingMode:synchronizationMode:error:_))]
#[unsafe(method_family = init)]
pub unsafe fn initWithURL_readOnly_cachingMode_synchronizationMode_error(
this: Allocated<Self>,
url: &NSURL,
read_only: bool,
caching_mode: VZDiskImageCachingMode,
synchronization_mode: VZDiskImageSynchronizationMode,
) -> Result<Retained<Self>, Retained<NSError>>;
/// URL of the underlying disk image.
#[unsafe(method(URL))]
#[unsafe(method_family = none)]
pub unsafe fn URL(&self) -> Retained<NSURL>;
/// Whether the underlying disk image is read-only.
#[unsafe(method(isReadOnly))]
#[unsafe(method_family = none)]
pub unsafe fn isReadOnly(&self) -> bool;
/// How disk image data is cached by the host.
#[unsafe(method(cachingMode))]
#[unsafe(method_family = none)]
pub unsafe fn cachingMode(&self) -> VZDiskImageCachingMode;
/// The mode in which the disk image synchronizes data with the underlying storage device.
#[unsafe(method(synchronizationMode))]
#[unsafe(method_family = none)]
pub unsafe fn synchronizationMode(&self) -> VZDiskImageSynchronizationMode;
);
}
/// Methods declared on superclass `VZStorageDeviceAttachment`.
#[cfg(feature = "VZStorageDeviceAttachment")]
impl VZDiskImageStorageDeviceAttachment {
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>;
);
}