objc2-virtualization 0.3.2

Bindings to the Virtualization framework
Documentation
//! 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!(
    /// Configuration of a paravirtualized storage device of type Virtio Block Device.
    ///
    /// This device configuration creates a storage device using paravirtualization.
    /// The emulated device follows the Virtio Block Device specification.
    ///
    /// The host implementation of the device is done through an attachment subclassing VZStorageDeviceAttachment
    /// like VZDiskImageStorageDeviceAttachment.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzvirtioblockdeviceconfiguration?language=objc)
    #[unsafe(super(VZStorageDeviceConfiguration, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "VZStorageDeviceConfiguration")]
    pub struct VZVirtioBlockDeviceConfiguration;
);

#[cfg(feature = "VZStorageDeviceConfiguration")]
extern_conformance!(
    unsafe impl NSCopying for VZVirtioBlockDeviceConfiguration {}
);

#[cfg(feature = "VZStorageDeviceConfiguration")]
unsafe impl CopyingHelper for VZVirtioBlockDeviceConfiguration {
    type Result = Self;
}

#[cfg(feature = "VZStorageDeviceConfiguration")]
extern_conformance!(
    unsafe impl NSObjectProtocol for VZVirtioBlockDeviceConfiguration {}
);

#[cfg(feature = "VZStorageDeviceConfiguration")]
impl VZVirtioBlockDeviceConfiguration {
    extern_methods!(
        #[cfg(feature = "VZStorageDeviceAttachment")]
        /// Initialize a VZVirtioBlockDeviceConfiguration with a device attachment.
        ///
        /// Parameter `attachment`: The storage device attachment. This defines how the virtualized device operates on the host side.
        ///
        /// See: VZDiskImageStorageDeviceAttachment
        #[unsafe(method(initWithAttachment:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithAttachment(
            this: Allocated<Self>,
            attachment: &VZStorageDeviceAttachment,
        ) -> Retained<Self>;

        /// Check if blockDeviceIdentifier is a valid Virtio block device identifier.
        ///
        /// Parameter `blockDeviceIdentifier`: The device identifier to validate.
        ///
        /// Parameter `error`: If not nil, assigned with an error describing why the device identifier is not valid.
        ///
        /// The device identifier must be at most 20 bytes in length and ASCII-encodable.
        #[unsafe(method(validateBlockDeviceIdentifier:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn validateBlockDeviceIdentifier_error(
            block_device_identifier: &NSString,
        ) -> Result<(), Retained<NSError>>;

        /// The device identifier is a string identifying the Virtio block device. Empty string by default.
        ///
        /// The identifier can be retrieved in the guest via a VIRTIO_BLK_T_GET_ID request.
        ///
        /// The identifier must be encodable as an ASCII string of length at most 20 bytes.
        /// This property can be checked with +[VZVirtioBlockDeviceConfiguration validateBlockDeviceIdentifier:error:].
        ///
        /// See: +[VZVirtioBlockDeviceConfiguration validateBlockDeviceIdentifier:error:]
        #[unsafe(method(blockDeviceIdentifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn blockDeviceIdentifier(&self) -> Retained<NSString>;

        /// Setter for [`blockDeviceIdentifier`][Self::blockDeviceIdentifier].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setBlockDeviceIdentifier:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setBlockDeviceIdentifier(&self, block_device_identifier: &NSString);
    );
}

/// Methods declared on superclass `VZStorageDeviceConfiguration`.
#[cfg(feature = "VZStorageDeviceConfiguration")]
impl VZVirtioBlockDeviceConfiguration {
    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>;
    );
}