objc2-metal 0.3.2

Bindings to the Metal 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!(
    /// Groups together parameters for creating a command allocator.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4commandallocatordescriptor?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MTL4CommandAllocatorDescriptor;
);

extern_conformance!(
    unsafe impl NSCopying for MTL4CommandAllocatorDescriptor {}
);

unsafe impl CopyingHelper for MTL4CommandAllocatorDescriptor {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for MTL4CommandAllocatorDescriptor {}
);

impl MTL4CommandAllocatorDescriptor {
    extern_methods!(
        /// An optional label you can assign to the command allocator to aid debugging.
        #[unsafe(method(label))]
        #[unsafe(method_family = none)]
        pub fn label(&self) -> Option<Retained<NSString>>;

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

/// Methods declared on superclass `NSObject`.
impl MTL4CommandAllocatorDescriptor {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

impl DefaultRetained for MTL4CommandAllocatorDescriptor {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

extern_protocol!(
    /// Manages the memory backing the encoding of GPU commands into command buffers.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4commandallocator?language=objc)
    pub unsafe trait MTL4CommandAllocator: NSObjectProtocol {
        #[cfg(feature = "MTLDevice")]
        /// Returns the GPU device that this command allocator belongs to.
        #[unsafe(method(device))]
        #[unsafe(method_family = none)]
        fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;

        /// Provides the optional label you specify at creation time for debug purposes.
        #[unsafe(method(label))]
        #[unsafe(method_family = none)]
        fn label(&self) -> Option<Retained<NSString>>;

        /// Queries the size of the internal memory heaps of this command allocator that support encoding
        /// commands into command buffers.
        ///
        /// - Returns: a size in bytes.
        #[unsafe(method(allocatedSize))]
        #[unsafe(method_family = none)]
        fn allocatedSize(&self) -> u64;

        /// Marks the command allocator's heaps for reuse.
        ///
        /// Calling this method allows new ``MTL4CommandBuffer`` to reuse its existing internal
        /// memory heaps to encode new GPU commands.
        ///
        /// You are responsible to ensure that all command buffers with memory originating
        /// from this allocator instance are complete before calling resetting it.
        #[unsafe(method(reset))]
        #[unsafe(method_family = none)]
        fn reset(&self);
    }
);