objc2_virtualization/generated/
VZVirtioSocketDevice.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// Virtio Socket Device
12    ///
13    /// This is a paravirtualized socket device which facilitates data transfer between the guest and the host without using Ethernet or IP protocols.
14    /// This device is created through instantiating a VZVirtioSocketDeviceConfiguration in a VZVirtualMachineConfiguration and is available in the VZVirtualMachine.socketDevices property.
15    ///
16    /// See: VZVirtioSocketDeviceConfiguration
17    ///
18    /// See: VZVirtioSocketDeviceConnection
19    ///
20    /// See: VZVirtioSocketDeviceListener
21    ///
22    /// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzvirtiosocketdevice?language=objc)
23    #[unsafe(super(VZSocketDevice, NSObject))]
24    #[derive(Debug, PartialEq, Eq, Hash)]
25    #[cfg(feature = "VZSocketDevice")]
26    pub struct VZVirtioSocketDevice;
27);
28
29#[cfg(feature = "VZSocketDevice")]
30extern_conformance!(
31    unsafe impl NSObjectProtocol for VZVirtioSocketDevice {}
32);
33
34#[cfg(feature = "VZSocketDevice")]
35impl VZVirtioSocketDevice {
36    extern_methods!(
37        #[unsafe(method(new))]
38        #[unsafe(method_family = new)]
39        pub unsafe fn new() -> Retained<Self>;
40
41        #[unsafe(method(init))]
42        #[unsafe(method_family = init)]
43        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
44
45        #[cfg(feature = "VZVirtioSocketListener")]
46        /// Sets a listener at a specified port.
47        ///
48        /// There is only one listener per port, any existing listener will be removed, and the specified listener here will be set instead.
49        /// The same listener can be registered on multiple ports.
50        /// The listener's delegate will be called whenever the guest connects to that port.
51        ///
52        /// Parameter `listener`: The VZVirtioSocketListener object to be set.
53        ///
54        /// Parameter `port`: The port number to set the listener at.
55        #[unsafe(method(setSocketListener:forPort:))]
56        #[unsafe(method_family = none)]
57        pub unsafe fn setSocketListener_forPort(
58            &self,
59            listener: &VZVirtioSocketListener,
60            port: u32,
61        );
62
63        /// Removes the listener at a specified port.
64        ///
65        /// Does nothing if the port had no listener.
66        ///
67        /// Parameter `port`: The port number at which the listener is to be removed.
68        #[unsafe(method(removeSocketListenerForPort:))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn removeSocketListenerForPort(&self, port: u32);
71
72        #[cfg(all(feature = "VZVirtioSocketConnection", feature = "block2"))]
73        /// Connects to a specified port.
74        ///
75        /// Does nothing if the guest does not listen on that port.
76        ///
77        /// Parameter `port`: The port number to connect to.
78        ///
79        /// Parameter `completionHandler`: Block called after the connection has been successfully established or on error.
80        /// The error parameter passed to the block is nil if the connection was successful.
81        #[unsafe(method(connectToPort:completionHandler:))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn connectToPort_completionHandler(
84            &self,
85            port: u32,
86            completion_handler: &block2::DynBlock<
87                dyn Fn(*mut VZVirtioSocketConnection, *mut NSError),
88            >,
89        );
90    );
91}