objc2-tv-services 0.3.2

Bindings to the TVServices framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// An object that represents a collection of Top Shelf items that can be displayed in a section.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/tvservices/tvtopshelfitemcollection?language=objc)
    #[unsafe(super(TVTopShelfObject, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "TVTopShelfItem", feature = "TVTopShelfObject"))]
    pub struct TVTopShelfItemCollection<Item: ?Sized = AnyObject>;
);

#[cfg(all(feature = "TVTopShelfItem", feature = "TVTopShelfObject"))]
impl<Item: ?Sized + Message + AsRef<TVTopShelfItem>> TVTopShelfItemCollection<Item> {
    /// Unchecked conversion of the generic parameter.
    ///
    /// # Safety
    ///
    /// The generic must be valid to reinterpret as the given type.
    #[inline]
    pub unsafe fn cast_unchecked<NewItem: ?Sized + Message + AsRef<TVTopShelfItem>>(
        &self,
    ) -> &TVTopShelfItemCollection<NewItem> {
        unsafe { &*((self as *const Self).cast()) }
    }
}

#[cfg(all(feature = "TVTopShelfItem", feature = "TVTopShelfObject"))]
extern_conformance!(
    unsafe impl<Item: ?Sized + AsRef<TVTopShelfItem>> NSObjectProtocol
        for TVTopShelfItemCollection<Item>
    {
    }
);

#[cfg(all(feature = "TVTopShelfItem", feature = "TVTopShelfObject"))]
impl<Item: Message + AsRef<TVTopShelfItem>> TVTopShelfItemCollection<Item> {
    extern_methods!(
        /// The collection's items.
        #[unsafe(method(items))]
        #[unsafe(method_family = none)]
        pub unsafe fn items(&self) -> Retained<NSArray<Item>>;

        /// Create a collection of items.
        #[unsafe(method(initWithItems:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithItems(this: Allocated<Self>, items: &NSArray<Item>)
            -> Retained<Self>;
    );
}

/// Methods declared on superclass `TVTopShelfObject`.
#[cfg(all(feature = "TVTopShelfItem", feature = "TVTopShelfObject"))]
impl<Item: Message + AsRef<TVTopShelfItem>> TVTopShelfItemCollection<Item> {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

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