objc2_tv_services/generated/
TVTopShelfItem.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
10/// A set of traits that allows the system to request variants of an image.
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/tvservices/tvtopshelfitemimagetraits?language=objc)
13// NS_OPTIONS
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct TVTopShelfItemImageTraits(pub NSUInteger);
17bitflags::bitflags! {
18    impl TVTopShelfItemImageTraits: NSUInteger {
19/// Variant used when the device is running in 1x.
20        #[doc(alias = "TVTopShelfItemImageTraitScreenScale1x")]
21        const ScreenScale1x = 1<<0;
22/// Variant used when the device is running in 2x.
23        #[doc(alias = "TVTopShelfItemImageTraitScreenScale2x")]
24        const ScreenScale2x = 2<<0;
25    }
26}
27
28unsafe impl Encode for TVTopShelfItemImageTraits {
29    const ENCODING: Encoding = NSUInteger::ENCODING;
30}
31
32unsafe impl RefEncode for TVTopShelfItemImageTraits {
33    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36extern_class!(
37    /// The base class for describing Top Shelf content to the system.
38    ///
39    /// See also [Apple's documentation](https://developer.apple.com/documentation/tvservices/tvtopshelfitem?language=objc)
40    #[unsafe(super(TVTopShelfObject, NSObject))]
41    #[derive(Debug, PartialEq, Eq, Hash)]
42    #[cfg(feature = "TVTopShelfObject")]
43    pub struct TVTopShelfItem;
44);
45
46#[cfg(feature = "TVTopShelfObject")]
47extern_conformance!(
48    unsafe impl NSObjectProtocol for TVTopShelfItem {}
49);
50
51#[cfg(feature = "TVTopShelfObject")]
52impl TVTopShelfItem {
53    extern_methods!(
54        /// The item's unique identifier.
55        ///
56        /// This identifier must be unique in the set of items you return to the system.
57        #[unsafe(method(identifier))]
58        #[unsafe(method_family = none)]
59        pub unsafe fn identifier(&self) -> Retained<NSString>;
60
61        #[cfg(feature = "TVTopShelfAction")]
62        /// The action performed when the user wants to play an item.
63        ///
64        /// 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.
65        #[unsafe(method(playAction))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn playAction(&self) -> Option<Retained<TVTopShelfAction>>;
68
69        #[cfg(feature = "TVTopShelfAction")]
70        /// Setter for [`playAction`][Self::playAction].
71        #[unsafe(method(setPlayAction:))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn setPlayAction(&self, play_action: Option<&TVTopShelfAction>);
74
75        #[cfg(feature = "TVTopShelfAction")]
76        /// The action performed when the user wants to see more information about an item.
77        ///
78        /// 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.
79        #[unsafe(method(displayAction))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn displayAction(&self) -> Option<Retained<TVTopShelfAction>>;
82
83        #[cfg(feature = "TVTopShelfAction")]
84        /// Setter for [`displayAction`][Self::displayAction].
85        #[unsafe(method(setDisplayAction:))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn setDisplayAction(&self, display_action: Option<&TVTopShelfAction>);
88
89        /// The date when the user will no longer be able to access the item.
90        #[unsafe(method(expirationDate))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn expirationDate(&self) -> Option<Retained<NSDate>>;
93
94        /// Setter for [`expirationDate`][Self::expirationDate].
95        ///
96        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
97        #[unsafe(method(setExpirationDate:))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn setExpirationDate(&self, expiration_date: Option<&NSDate>);
100
101        /// Set an image URL for the given combination of traits.
102        ///
103        /// 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.
104        #[unsafe(method(setImageURL:forTraits:))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn setImageURL_forTraits(
107            &self,
108            image_url: Option<&NSURL>,
109            traits: TVTopShelfItemImageTraits,
110        );
111
112        /// Get the image URL for the given combination of traits.
113        ///
114        /// 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.
115        #[unsafe(method(imageURLForTraits:))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn imageURLForTraits(
118            &self,
119            traits: TVTopShelfItemImageTraits,
120        ) -> Option<Retained<NSURL>>;
121
122        /// Create an item with a unique identifier.
123        ///
124        /// This identifier must be unique in the set of items you return to the system.
125        #[unsafe(method(initWithIdentifier:))]
126        #[unsafe(method_family = init)]
127        pub unsafe fn initWithIdentifier(
128            this: Allocated<Self>,
129            identifier: &NSString,
130        ) -> Retained<Self>;
131    );
132}
133
134/// Methods declared on superclass `TVTopShelfObject`.
135#[cfg(feature = "TVTopShelfObject")]
136impl TVTopShelfItem {
137    extern_methods!(
138        #[unsafe(method(init))]
139        #[unsafe(method_family = init)]
140        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
141
142        #[unsafe(method(new))]
143        #[unsafe(method_family = new)]
144        pub unsafe fn new() -> Retained<Self>;
145    );
146}