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::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// A set of traits that allows the system to request variants of an image.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/tvservices/tvtopshelfitemimagetraits?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct TVTopShelfItemImageTraits(pub NSUInteger);
bitflags::bitflags! {
    impl TVTopShelfItemImageTraits: NSUInteger {
/// Variant used when the device is running in 1x.
        #[doc(alias = "TVTopShelfItemImageTraitScreenScale1x")]
        const ScreenScale1x = 1<<0;
/// Variant used when the device is running in 2x.
        #[doc(alias = "TVTopShelfItemImageTraitScreenScale2x")]
        const ScreenScale2x = 2<<0;
    }
}

unsafe impl Encode for TVTopShelfItemImageTraits {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for TVTopShelfItemImageTraits {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// The base class for describing Top Shelf content to the system.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/tvservices/tvtopshelfitem?language=objc)
    #[unsafe(super(TVTopShelfObject, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "TVTopShelfObject")]
    pub struct TVTopShelfItem;
);

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

#[cfg(feature = "TVTopShelfObject")]
impl TVTopShelfItem {
    extern_methods!(
        /// The item's unique identifier.
        ///
        /// This identifier must be unique in the set of items you return to the system.
        #[unsafe(method(identifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn identifier(&self) -> Retained<NSString>;

        #[cfg(feature = "TVTopShelfAction")]
        /// The action performed when the user wants to play an item.
        ///
        /// In sectioned and inset content styles this action is used when the user presses the play/pause button when the item is focused. In carousel content styles this is the first button shown to the user.
        #[unsafe(method(playAction))]
        #[unsafe(method_family = none)]
        pub unsafe fn playAction(&self) -> Option<Retained<TVTopShelfAction>>;

        #[cfg(feature = "TVTopShelfAction")]
        /// Setter for [`playAction`][Self::playAction].
        #[unsafe(method(setPlayAction:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPlayAction(&self, play_action: Option<&TVTopShelfAction>);

        #[cfg(feature = "TVTopShelfAction")]
        /// The action performed when the user wants to see more information about an item.
        ///
        /// In sectioned and inset content styles this action is used when the user selects the item. In carousel content styles this is the second button shown to the user.
        #[unsafe(method(displayAction))]
        #[unsafe(method_family = none)]
        pub unsafe fn displayAction(&self) -> Option<Retained<TVTopShelfAction>>;

        #[cfg(feature = "TVTopShelfAction")]
        /// Setter for [`displayAction`][Self::displayAction].
        #[unsafe(method(setDisplayAction:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDisplayAction(&self, display_action: Option<&TVTopShelfAction>);

        /// The date when the user will no longer be able to access the item.
        #[unsafe(method(expirationDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn expirationDate(&self) -> Option<Retained<NSDate>>;

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

        /// Set an image URL for the given combination of traits.
        ///
        /// In sectioned and inset content styles this is the image displayed for the item. In carousel content styles this image is displayed before the preview video.
        #[unsafe(method(setImageURL:forTraits:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setImageURL_forTraits(
            &self,
            image_url: Option<&NSURL>,
            traits: TVTopShelfItemImageTraits,
        );

        /// Get the image URL for the given combination of traits.
        ///
        /// In sectioned and inset content styles this is the image displayed for the item. In carousel content styles this image is displayed before the preview video.
        #[unsafe(method(imageURLForTraits:))]
        #[unsafe(method_family = none)]
        pub unsafe fn imageURLForTraits(
            &self,
            traits: TVTopShelfItemImageTraits,
        ) -> Option<Retained<NSURL>>;

        /// Create an item with a unique identifier.
        ///
        /// This identifier must be unique in the set of items you return to the system.
        #[unsafe(method(initWithIdentifier:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithIdentifier(
            this: Allocated<Self>,
            identifier: &NSString,
        ) -> Retained<Self>;
    );
}

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