objc2_metal_performance_shaders_graph/generated/
MPSGraphDevice.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_metal::*;
6
7use crate::*;
8
9/// The device type.
10///
11/// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshadersgraph/mpsgraphdevicetype?language=objc)
12// NS_ENUM
13#[repr(transparent)]
14#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct MPSGraphDeviceType(pub u32);
16impl MPSGraphDeviceType {
17    /// Device of type Metal
18    #[doc(alias = "MPSGraphDeviceTypeMetal")]
19    pub const Metal: Self = Self(0);
20}
21
22unsafe impl Encode for MPSGraphDeviceType {
23    const ENCODING: Encoding = u32::ENCODING;
24}
25
26unsafe impl RefEncode for MPSGraphDeviceType {
27    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
28}
29
30extern_class!(
31    /// A class that describes the compute device.
32    ///
33    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshadersgraph/mpsgraphdevice?language=objc)
34    #[unsafe(super(MPSGraphObject, NSObject))]
35    #[derive(Debug, PartialEq, Eq, Hash)]
36    #[cfg(feature = "MPSGraphCore")]
37    pub struct MPSGraphDevice;
38);
39
40#[cfg(feature = "MPSGraphCore")]
41extern_conformance!(
42    unsafe impl NSObjectProtocol for MPSGraphDevice {}
43);
44
45#[cfg(feature = "MPSGraphCore")]
46impl MPSGraphDevice {
47    extern_methods!(
48        /// Device of the MPSGraphDevice.
49        #[unsafe(method(type))]
50        #[unsafe(method_family = none)]
51        pub unsafe fn r#type(&self) -> MPSGraphDeviceType;
52
53        /// If device type is Metal then returns the corresponding MTLDevice else nil.
54        #[unsafe(method(metalDevice))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn metalDevice(&self) -> Option<Retained<ProtocolObject<dyn MTLDevice>>>;
57
58        /// Creates a device from a given Metal device.
59        ///
60        /// - Parameters:
61        /// - metalDevice: `MTLDevice` to create an MPSGraphDevice from.
62        /// - Returns: A valid device.
63        #[unsafe(method(deviceWithMTLDevice:))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn deviceWithMTLDevice(
66            metal_device: &ProtocolObject<dyn MTLDevice>,
67        ) -> Retained<Self>;
68    );
69}
70
71/// Methods declared on superclass `NSObject`.
72#[cfg(feature = "MPSGraphCore")]
73impl MPSGraphDevice {
74    extern_methods!(
75        #[unsafe(method(init))]
76        #[unsafe(method_family = init)]
77        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
78
79        #[unsafe(method(new))]
80        #[unsafe(method_family = new)]
81        pub unsafe fn new() -> Retained<Self>;
82    );
83}