objc2_ui_kit/generated/
UIDeferredMenuElement.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/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uideferredmenuelementidentifier?language=objc)
11// NS_TYPED_EXTENSIBLE_ENUM
12pub type UIDeferredMenuElementIdentifier = NSString;
13
14extern_class!(
15    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uideferredmenuelement?language=objc)
16    #[unsafe(super(UIMenuElement, NSObject))]
17    #[thread_kind = MainThreadOnly]
18    #[derive(Debug, PartialEq, Eq, Hash)]
19    #[cfg(feature = "UIMenuElement")]
20    pub struct UIDeferredMenuElement;
21);
22
23#[cfg(feature = "UIMenuElement")]
24extern_conformance!(
25    unsafe impl NSCoding for UIDeferredMenuElement {}
26);
27
28#[cfg(feature = "UIMenuElement")]
29extern_conformance!(
30    unsafe impl NSCopying for UIDeferredMenuElement {}
31);
32
33#[cfg(feature = "UIMenuElement")]
34unsafe impl CopyingHelper for UIDeferredMenuElement {
35    type Result = Self;
36}
37
38#[cfg(feature = "UIMenuElement")]
39extern_conformance!(
40    unsafe impl NSObjectProtocol for UIDeferredMenuElement {}
41);
42
43#[cfg(feature = "UIMenuElement")]
44extern_conformance!(
45    unsafe impl NSSecureCoding for UIDeferredMenuElement {}
46);
47
48#[cfg(feature = "UIMenuElement")]
49impl UIDeferredMenuElement {
50    extern_methods!(
51        /// The identifier of this deferred menu element.
52        #[unsafe(method(identifier))]
53        #[unsafe(method_family = none)]
54        pub fn identifier(&self) -> Retained<UIDeferredMenuElementIdentifier>;
55
56        #[cfg(feature = "block2")]
57        /// Returns a placeholder menu element that is replaced with the result of the block's
58        /// completion handler. A loading UI takes the place of the element in the menu
59        /// until it is fulfilled. While the element may be stored and re-used across menus, its block is
60        /// called only once, when the element is first encountered in a menu.
61        ///
62        ///
63        /// Parameter `elementProvider`: Called by the system to request the deferred menu items when the containing menu is presented.
64        /// Call this block's completion handler when the menu items are available.
65        ///
66        /// # Safety
67        ///
68        /// `element_provider` block's argument block's argument must be a valid pointer.
69        #[unsafe(method(elementWithProvider:))]
70        #[unsafe(method_family = none)]
71        pub unsafe fn elementWithProvider(
72            element_provider: &block2::DynBlock<
73                dyn Fn(NonNull<block2::DynBlock<dyn Fn(NonNull<NSArray<UIMenuElement>>)>>),
74            >,
75            mtm: MainThreadMarker,
76        ) -> Retained<Self>;
77
78        #[cfg(feature = "block2")]
79        /// Returns a placeholder menu element that is replaced with the result of the block's
80        /// completion handler. A loading UI takes the place of the element in the menu
81        /// until it is fulfilled. Elements created using this initializer are "uncached",
82        /// so their
83        /// `elementProvider`block is called every time the element is displayed.
84        ///
85        ///
86        /// Parameter `elementProvider`: Called by the system to request the deferred menu items when the containing menu is presented.
87        /// Call this block's completion handler when the menu items are available.
88        ///
89        /// # Safety
90        ///
91        /// `element_provider` block's argument block's argument must be a valid pointer.
92        #[unsafe(method(elementWithUncachedProvider:))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn elementWithUncachedProvider(
95            element_provider: &block2::DynBlock<
96                dyn Fn(NonNull<block2::DynBlock<dyn Fn(NonNull<NSArray<UIMenuElement>>)>>),
97            >,
98            mtm: MainThreadMarker,
99        ) -> Retained<Self>;
100
101        /// Returns a placeholder menu element that is replaced with elements provided from the responder chain.
102        /// A loading UI takes the place of the element in the menu until it is fulfilled. The element may be stored
103        /// and re-used across menus.
104        ///
105        ///
106        /// Parameter `identifier`: An identifier for this deferred element that responders can check to determine which elements
107        /// to provide.
108        ///
109        /// Parameter `shouldCacheItems`: Whether or not the deferred element caches items. Passing in
110        /// `YES`causes this deferred element to
111        /// ask the responder chain for elements only once, when the element is first encountered in a menu.
112        /// Passing in
113        /// `NO`asks the responder chain for elements every time the element is displayed.
114        #[unsafe(method(elementUsingFocusWithIdentifier:shouldCacheItems:))]
115        #[unsafe(method_family = none)]
116        pub fn elementUsingFocusWithIdentifier_shouldCacheItems(
117            identifier: &UIDeferredMenuElementIdentifier,
118            should_cache_items: bool,
119            mtm: MainThreadMarker,
120        ) -> Retained<Self>;
121    );
122}
123
124/// Methods declared on superclass `UIMenuElement`.
125#[cfg(feature = "UIMenuElement")]
126impl UIDeferredMenuElement {
127    extern_methods!(
128        /// # Safety
129        ///
130        /// `coder` possibly has further requirements.
131        #[unsafe(method(initWithCoder:))]
132        #[unsafe(method_family = init)]
133        pub unsafe fn initWithCoder(
134            this: Allocated<Self>,
135            coder: &NSCoder,
136        ) -> Option<Retained<Self>>;
137
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(mtm: MainThreadMarker) -> Retained<Self>;
145    );
146}
147
148extern_class!(
149    /// Represents an element provider for a deferred menu element.
150    /// When the containing menu for a responder-based deferred element is presented, the system asks the
151    /// responder chain for one of these element providers for the deferred element.
152    ///
153    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uideferredmenuelementprovider?language=objc)
154    #[unsafe(super(NSObject))]
155    #[thread_kind = MainThreadOnly]
156    #[derive(Debug, PartialEq, Eq, Hash)]
157    pub struct UIDeferredMenuElementProvider;
158);
159
160extern_conformance!(
161    unsafe impl NSObjectProtocol for UIDeferredMenuElementProvider {}
162);
163
164impl UIDeferredMenuElementProvider {
165    extern_methods!(
166        #[cfg(all(feature = "UIMenuElement", feature = "block2"))]
167        /// Creates a deferred menu element provider with an asynchronous block.
168        ///
169        ///
170        /// Parameter `elementProvider`: An asynchronous element provider block. Call this block's completion handler when the responder's
171        /// menu items are available.
172        ///
173        /// # Safety
174        ///
175        /// `element_provider` block's argument block's argument must be a valid pointer.
176        #[unsafe(method(providerWithElementProvider:))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn providerWithElementProvider(
179            element_provider: &block2::DynBlock<
180                dyn Fn(NonNull<block2::DynBlock<dyn Fn(NonNull<NSArray<UIMenuElement>>)>>),
181            >,
182            mtm: MainThreadMarker,
183        ) -> Retained<Self>;
184
185        #[unsafe(method(init))]
186        #[unsafe(method_family = init)]
187        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
188
189        #[unsafe(method(new))]
190        #[unsafe(method_family = new)]
191        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
192    );
193}