objc2_virtualization/generated/VZDiskImageStorageDeviceAttachment.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9/// Whether the host caches disk image data.
10///
11/// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzdiskimagecachingmode?language=objc)
12// NS_ENUM
13#[repr(transparent)]
14#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct VZDiskImageCachingMode(pub NSInteger);
16impl VZDiskImageCachingMode {
17 #[doc(alias = "VZDiskImageCachingModeAutomatic")]
18 pub const Automatic: Self = Self(0);
19 #[doc(alias = "VZDiskImageCachingModeUncached")]
20 pub const Uncached: Self = Self(1);
21 #[doc(alias = "VZDiskImageCachingModeCached")]
22 pub const Cached: Self = Self(2);
23}
24
25unsafe impl Encode for VZDiskImageCachingMode {
26 const ENCODING: Encoding = NSInteger::ENCODING;
27}
28
29unsafe impl RefEncode for VZDiskImageCachingMode {
30 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
31}
32
33/// [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzdiskimagesynchronizationmode?language=objc)
34// NS_ENUM
35#[repr(transparent)]
36#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
37pub struct VZDiskImageSynchronizationMode(pub NSInteger);
38impl VZDiskImageSynchronizationMode {
39 /// The data is synchronized to the permanent storage holding the disk image.
40 /// No synchronized data is lost on panic or loss of power.
41 #[doc(alias = "VZDiskImageSynchronizationModeFull")]
42 pub const Full: Self = Self(1);
43 /// Synchronize the data to the drive.
44 ///
45 /// This mode synchronizes the data with the drive, but does not ensure the data is moved from the disk's internal cache
46 /// to permanent storage.
47 ///
48 /// This is a best-effort mode with the same guarantees as the fsync() system call.
49 #[doc(alias = "VZDiskImageSynchronizationModeFsync")]
50 pub const Fsync: Self = Self(2);
51 /// Do not synchronize the data with the permanent storage.
52 /// This option does not guarantee data integrity if any error condition occurs such as disk full on the host,
53 /// panic, power loss, etc.
54 ///
55 /// This mode is useful when a virtual machine is only run once to perform a task to completion or failure.
56 /// In that case, the disk image cannot safely be reused on failure.
57 ///
58 /// Using this mode may result in improved performance since no synchronization with the underlying storage is necessary.
59 #[doc(alias = "VZDiskImageSynchronizationModeNone")]
60 pub const None: Self = Self(3);
61}
62
63unsafe impl Encode for VZDiskImageSynchronizationMode {
64 const ENCODING: Encoding = NSInteger::ENCODING;
65}
66
67unsafe impl RefEncode for VZDiskImageSynchronizationMode {
68 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
69}
70
71extern_class!(
72 /// Storage device attachment using a disk image to implement the storage.
73 ///
74 /// This storage device attachment uses a disk image on the host file system as the drive of the storage device.
75 ///
76 /// Only RAW data disk images are supported.
77 ///
78 /// An empty RAW disk image can be created with `FileDescriptor.resize(to:retryOnInterrupt:)` method in Swift,
79 /// the `ftruncate()` function in Swift or Objective-C, or the `truncate` command on the command line.
80 /// The size of the file must be a multiple of 512 bytes, the block size.
81 ///
82 /// See: VZNVMExpressControllerDeviceConfiguration
83 ///
84 /// See: VZUSBMassStorageDeviceConfiguration
85 ///
86 /// See: VZVirtioBlockDeviceConfiguration
87 ///
88 /// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzdiskimagestoragedeviceattachment?language=objc)
89 #[unsafe(super(VZStorageDeviceAttachment, NSObject))]
90 #[derive(Debug, PartialEq, Eq, Hash)]
91 #[cfg(feature = "VZStorageDeviceAttachment")]
92 pub struct VZDiskImageStorageDeviceAttachment;
93);
94
95#[cfg(feature = "VZStorageDeviceAttachment")]
96extern_conformance!(
97 unsafe impl NSObjectProtocol for VZDiskImageStorageDeviceAttachment {}
98);
99
100#[cfg(feature = "VZStorageDeviceAttachment")]
101impl VZDiskImageStorageDeviceAttachment {
102 extern_methods!(
103 /// Initialize the attachment from a local file url.
104 ///
105 /// Parameter `url`: Local file URL to the disk image in RAW format.
106 ///
107 /// Parameter `readOnly`: If YES, the device attachment is read-only, otherwise the device can write data to the disk image.
108 ///
109 /// Parameter `error`: If not nil, assigned with the error if the initialization failed.
110 ///
111 /// Returns: A newly initialized VZDiskImageStorageDeviceAttachment. If an error was encountered returns
112 /// `nil,`and
113 /// `error`contains the error.
114 #[unsafe(method(initWithURL:readOnly:error:_))]
115 #[unsafe(method_family = init)]
116 pub unsafe fn initWithURL_readOnly_error(
117 this: Allocated<Self>,
118 url: &NSURL,
119 read_only: bool,
120 ) -> Result<Retained<Self>, Retained<NSError>>;
121
122 /// Initialize the attachment from a local file url.
123 ///
124 /// Parameter `url`: Local file URL to the disk image in RAW format.
125 ///
126 /// Parameter `readOnly`: If YES, the device attachment is read-only, otherwise the device can write data to the disk image.
127 ///
128 /// Parameter `cachingMode`: Whether host data caching is enabled for the disk image.
129 ///
130 /// Parameter `synchronizationMode`: How the disk image synchronizes with the underlying storage when the guest operating system flushes data.
131 ///
132 /// Parameter `error`: If not nil, assigned with the error if the initialization failed.
133 ///
134 /// Returns: A newly initialized VZDiskImageStorageDeviceAttachment. If an error was encountered returns
135 /// `nil,`and
136 /// `error`contains the error.
137 #[unsafe(method(initWithURL:readOnly:cachingMode:synchronizationMode:error:_))]
138 #[unsafe(method_family = init)]
139 pub unsafe fn initWithURL_readOnly_cachingMode_synchronizationMode_error(
140 this: Allocated<Self>,
141 url: &NSURL,
142 read_only: bool,
143 caching_mode: VZDiskImageCachingMode,
144 synchronization_mode: VZDiskImageSynchronizationMode,
145 ) -> Result<Retained<Self>, Retained<NSError>>;
146
147 /// URL of the underlying disk image.
148 #[unsafe(method(URL))]
149 #[unsafe(method_family = none)]
150 pub unsafe fn URL(&self) -> Retained<NSURL>;
151
152 /// Whether the underlying disk image is read-only.
153 #[unsafe(method(isReadOnly))]
154 #[unsafe(method_family = none)]
155 pub unsafe fn isReadOnly(&self) -> bool;
156
157 /// How disk image data is cached by the host.
158 #[unsafe(method(cachingMode))]
159 #[unsafe(method_family = none)]
160 pub unsafe fn cachingMode(&self) -> VZDiskImageCachingMode;
161
162 /// The mode in which the disk image synchronizes data with the underlying storage device.
163 #[unsafe(method(synchronizationMode))]
164 #[unsafe(method_family = none)]
165 pub unsafe fn synchronizationMode(&self) -> VZDiskImageSynchronizationMode;
166 );
167}
168
169/// Methods declared on superclass `VZStorageDeviceAttachment`.
170#[cfg(feature = "VZStorageDeviceAttachment")]
171impl VZDiskImageStorageDeviceAttachment {
172 extern_methods!(
173 #[unsafe(method(new))]
174 #[unsafe(method_family = new)]
175 pub unsafe fn new() -> Retained<Self>;
176
177 #[unsafe(method(init))]
178 #[unsafe(method_family = init)]
179 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
180 );
181}