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 /// See: VZNVMExpressControllerDeviceConfiguration
79 ///
80 /// See: VZUSBMassStorageDeviceConfiguration
81 ///
82 /// See: VZVirtioBlockDeviceConfiguration
83 ///
84 /// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzdiskimagestoragedeviceattachment?language=objc)
85 #[unsafe(super(VZStorageDeviceAttachment, NSObject))]
86 #[derive(Debug, PartialEq, Eq, Hash)]
87 #[cfg(feature = "VZStorageDeviceAttachment")]
88 pub struct VZDiskImageStorageDeviceAttachment;
89);
90
91#[cfg(feature = "VZStorageDeviceAttachment")]
92extern_conformance!(
93 unsafe impl NSObjectProtocol for VZDiskImageStorageDeviceAttachment {}
94);
95
96#[cfg(feature = "VZStorageDeviceAttachment")]
97impl VZDiskImageStorageDeviceAttachment {
98 extern_methods!(
99 /// Initialize the attachment from a local file url.
100 ///
101 /// Parameter `url`: Local file URL to the disk image in RAW format.
102 ///
103 /// Parameter `readOnly`: If YES, the device attachment is read-only, otherwise the device can write data to the disk image.
104 ///
105 /// Parameter `error`: If not nil, assigned with the error if the initialization failed.
106 ///
107 /// Returns: A newly initialized VZDiskImageStorageDeviceAttachment. If an error was encountered returns
108 /// `nil,`and
109 /// `error`contains the error.
110 #[unsafe(method(initWithURL:readOnly:error:_))]
111 #[unsafe(method_family = init)]
112 pub unsafe fn initWithURL_readOnly_error(
113 this: Allocated<Self>,
114 url: &NSURL,
115 read_only: bool,
116 ) -> Result<Retained<Self>, Retained<NSError>>;
117
118 /// Initialize the attachment from a local file url.
119 ///
120 /// Parameter `url`: Local file URL to the disk image in RAW format.
121 ///
122 /// Parameter `readOnly`: If YES, the device attachment is read-only, otherwise the device can write data to the disk image.
123 ///
124 /// Parameter `cachingMode`: Whether host data caching is enabled for the disk image.
125 ///
126 /// Parameter `synchronizationMode`: How the disk image synchronizes with the underlying storage when the guest operating system flushes data.
127 ///
128 /// Parameter `error`: If not nil, assigned with the error if the initialization failed.
129 ///
130 /// Returns: A newly initialized VZDiskImageStorageDeviceAttachment. If an error was encountered returns
131 /// `nil,`and
132 /// `error`contains the error.
133 #[unsafe(method(initWithURL:readOnly:cachingMode:synchronizationMode:error:_))]
134 #[unsafe(method_family = init)]
135 pub unsafe fn initWithURL_readOnly_cachingMode_synchronizationMode_error(
136 this: Allocated<Self>,
137 url: &NSURL,
138 read_only: bool,
139 caching_mode: VZDiskImageCachingMode,
140 synchronization_mode: VZDiskImageSynchronizationMode,
141 ) -> Result<Retained<Self>, Retained<NSError>>;
142
143 /// URL of the underlying disk image.
144 #[unsafe(method(URL))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn URL(&self) -> Retained<NSURL>;
147
148 /// Whether the underlying disk image is read-only.
149 #[unsafe(method(isReadOnly))]
150 #[unsafe(method_family = none)]
151 pub unsafe fn isReadOnly(&self) -> bool;
152
153 /// How disk image data is cached by the host.
154 #[unsafe(method(cachingMode))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn cachingMode(&self) -> VZDiskImageCachingMode;
157
158 /// The mode in which the disk image synchronizes data with the underlying storage device.
159 #[unsafe(method(synchronizationMode))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn synchronizationMode(&self) -> VZDiskImageSynchronizationMode;
162 );
163}
164
165/// Methods declared on superclass `VZStorageDeviceAttachment`.
166#[cfg(feature = "VZStorageDeviceAttachment")]
167impl VZDiskImageStorageDeviceAttachment {
168 extern_methods!(
169 #[unsafe(method(new))]
170 #[unsafe(method_family = new)]
171 pub unsafe fn new() -> Retained<Self>;
172
173 #[unsafe(method(init))]
174 #[unsafe(method_family = init)]
175 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
176 );
177}