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