objc2_browser_engine_kit/generated/
BECapability.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::*;
6#[cfg(feature = "objc2-av-foundation")]
7use objc2_av_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_protocol!(
13    /// An object that represents a granted capability.
14    ///
15    /// See also [Apple's documentation](https://developer.apple.com/documentation/browserenginekit/beprocesscapabilitygrant?language=objc)
16    pub unsafe trait BEProcessCapabilityGrant: NSObjectProtocol {
17        /// Invalidates the grant, removing the capability from the process it was granted to.
18        #[unsafe(method(invalidate))]
19        #[unsafe(method_family = none)]
20        unsafe fn invalidate(&self) -> bool;
21
22        /// `YES` if the process has been granted the capability and the grant is still valid.
23        #[unsafe(method(isValid))]
24        #[unsafe(method_family = none)]
25        unsafe fn isValid(&self) -> bool;
26    }
27);
28
29extern_class!(
30    /// An object that represents a media playback environment
31    ///
32    /// See also [Apple's documentation](https://developer.apple.com/documentation/browserenginekit/bemediaenvironment?language=objc)
33    #[unsafe(super(NSObject))]
34    #[derive(Debug, PartialEq, Eq, Hash)]
35    pub struct BEMediaEnvironment;
36);
37
38extern_conformance!(
39    unsafe impl NSObjectProtocol for BEMediaEnvironment {}
40);
41
42impl BEMediaEnvironment {
43    extern_methods!(
44        #[unsafe(method(init))]
45        #[unsafe(method_family = init)]
46        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
47
48        #[unsafe(method(new))]
49        #[unsafe(method_family = new)]
50        pub unsafe fn new() -> Retained<Self>;
51
52        /// Creates a new media playback environment identified by the web page URL
53        ///
54        /// - Parameters:
55        /// - url: The URL identifying the media playback environment
56        #[unsafe(method(initWithWebPageURL:))]
57        #[unsafe(method_family = init)]
58        pub unsafe fn initWithWebPageURL(this: Allocated<Self>, url: &NSURL) -> Retained<Self>;
59
60        /// Activates the media environment.
61        #[unsafe(method(activateWithError:_))]
62        #[unsafe(method_family = none)]
63        pub unsafe fn activateWithError(&self) -> Result<(), Retained<NSError>>;
64
65        /// Suspends the media environment.
66        #[unsafe(method(suspendWithError:_))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn suspendWithError(&self) -> Result<(), Retained<NSError>>;
69
70        #[cfg(feature = "objc2-av-foundation")]
71        /// Creates a new capture session in this media environment.
72        ///
73        /// The media environment must be activated before the capture session can be started.
74        #[unsafe(method(makeCaptureSessionWithError:_))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn makeCaptureSessionWithError(
77            &self,
78        ) -> Result<Retained<AVCaptureSession>, Retained<NSError>>;
79    );
80}
81
82extern_class!(
83    /// An object representing capabilities that can be granted to a helper extension process.
84    ///
85    /// See also [Apple's documentation](https://developer.apple.com/documentation/browserenginekit/beprocesscapability?language=objc)
86    #[unsafe(super(NSObject))]
87    #[derive(Debug, PartialEq, Eq, Hash)]
88    pub struct BEProcessCapability;
89);
90
91extern_conformance!(
92    unsafe impl NSObjectProtocol for BEProcessCapability {}
93);
94
95impl BEProcessCapability {
96    extern_methods!(
97        /// The helper extension process may access AV hardware required for media capture and playback.
98        #[unsafe(method(mediaPlaybackAndCaptureWithEnvironment:))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn mediaPlaybackAndCaptureWithEnvironment(
101            environment: &BEMediaEnvironment,
102        ) -> Retained<Self>;
103
104        /// The helper extension process may run in the background to finish work.
105        #[unsafe(method(background))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn background() -> Retained<Self>;
108
109        /// The helper extension process may run at foreground priority to work on behalf of the host process while it is foreground.
110        #[unsafe(method(foreground))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn foreground() -> Retained<Self>;
113
114        /// The helper extension process may remain resident in a suspended state (it will not be granted CPU time).
115        #[unsafe(method(suspended))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn suspended() -> Retained<Self>;
118
119        /// Requests the capability to be granted to the current process.
120        ///
121        /// Returns the granted capability or nil and an error if it can not be granted
122        #[unsafe(method(requestWithError:_))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn requestWithError(
125            &self,
126        ) -> Result<Retained<ProtocolObject<dyn BEProcessCapabilityGrant>>, Retained<NSError>>;
127    );
128}
129
130/// Methods declared on superclass `NSObject`.
131impl BEProcessCapability {
132    extern_methods!(
133        #[unsafe(method(init))]
134        #[unsafe(method_family = init)]
135        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
136
137        #[unsafe(method(new))]
138        #[unsafe(method_family = new)]
139        pub unsafe fn new() -> Retained<Self>;
140    );
141}
142
143/// Capability.
144#[cfg(feature = "BEWebContentProcess")]
145impl BEWebContentProcess {
146    extern_methods!(
147        /// Grants the specified capability to the process.
148        ///
149        /// This method grants the specified capability to the process or returns nil and an error if it can not be granted.
150        ///
151        /// - Parameters:
152        /// - capability: The capability to be granted
153        /// - error: The error out param populated if the capability cannot be granted.
154        ///
155        /// - Returns: an invalidatable grant object that represents the granted capability.
156        #[unsafe(method(grantCapability:error:_))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn grantCapability_error(
159            &self,
160            capability: &BEProcessCapability,
161        ) -> Result<Retained<ProtocolObject<dyn BEProcessCapabilityGrant>>, Retained<NSError>>;
162    );
163}
164
165/// CapabilityInvalidationHandler.
166#[cfg(feature = "BEWebContentProcess")]
167impl BEWebContentProcess {
168    extern_methods!(
169        #[cfg(feature = "block2")]
170        /// Grants the specified capability to the process with invalidation handler.
171        ///
172        /// This method grants the specified capability to the process or returns nil and an error if it can not be granted.
173        ///
174        /// - Parameters:
175        /// - capability: The capability to be granted
176        /// - error: The error out param populated if the capability cannot be granted.
177        /// - invalidationHandler: The invalidation handler
178        ///
179        /// - Returns: an invalidatable grant object that represents the granted capability.
180        #[unsafe(method(grantCapability:error:invalidationHandler:))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn grantCapability_error_invalidationHandler(
183            &self,
184            capability: &BEProcessCapability,
185            error: Option<&mut Option<Retained<NSError>>>,
186            invalidation_handler: &block2::DynBlock<dyn Fn()>,
187        ) -> Option<Retained<ProtocolObject<dyn BEProcessCapabilityGrant>>>;
188    );
189}
190
191/// Capability.
192#[cfg(feature = "BERenderingProcess")]
193impl BERenderingProcess {
194    extern_methods!(
195        /// Grants the specified capability to the process.
196        ///
197        /// This method grants the specified capability to the process or returns nil and an error if it can not be granted.
198        ///
199        /// - Parameters:
200        /// - capability: The capability to be granted
201        /// - error: The error out param populated if the capability cannot be granted.
202        ///
203        /// - Returns: an invalidatable grant object that represents the granted capability.
204        #[unsafe(method(grantCapability:error:_))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn grantCapability_error(
207            &self,
208            capability: &BEProcessCapability,
209        ) -> Result<Retained<ProtocolObject<dyn BEProcessCapabilityGrant>>, Retained<NSError>>;
210    );
211}
212
213/// CapabilityInvalidationHandler.
214#[cfg(feature = "BERenderingProcess")]
215impl BERenderingProcess {
216    extern_methods!(
217        #[cfg(feature = "block2")]
218        /// Grants the specified capability to the process with invalidation handler.
219        ///
220        /// This method grants the specified capability to the process or returns nil and an error if it can not be granted.
221        ///
222        /// - Parameters:
223        /// - capability: The capability to be granted
224        /// - error: The error out param populated if the capability cannot be granted.
225        /// - invalidationHandler: The invalidation handler
226        ///
227        /// - Returns: an invalidatable grant object that represents the granted capability.
228        #[unsafe(method(grantCapability:error:invalidationHandler:))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn grantCapability_error_invalidationHandler(
231            &self,
232            capability: &BEProcessCapability,
233            error: Option<&mut Option<Retained<NSError>>>,
234            invalidation_handler: &block2::DynBlock<dyn Fn()>,
235        ) -> Option<Retained<ProtocolObject<dyn BEProcessCapabilityGrant>>>;
236    );
237}
238
239/// Capability.
240#[cfg(feature = "BENetworkingProcess")]
241impl BENetworkingProcess {
242    extern_methods!(
243        /// Grants the specified capability to the process.
244        ///
245        /// This method grants the specified capability to the process or returns nil and an error if it can not be granted.
246        ///
247        /// - Parameters:
248        /// - capability: The capability to be granted
249        /// - error: The error out param populated if the capability cannot be granted.
250        ///
251        /// - Returns: an invalidatable grant object that represents the granted capability.
252        #[unsafe(method(grantCapability:error:_))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn grantCapability_error(
255            &self,
256            capability: &BEProcessCapability,
257        ) -> Result<Retained<ProtocolObject<dyn BEProcessCapabilityGrant>>, Retained<NSError>>;
258    );
259}
260
261/// CapabilityInvalidationHandler.
262#[cfg(feature = "BENetworkingProcess")]
263impl BENetworkingProcess {
264    extern_methods!(
265        #[cfg(feature = "block2")]
266        /// Grants the specified capability to the process with invalidation handler.
267        ///
268        /// This method grants the specified capability to the process or returns nil and an error if it can not be granted.
269        ///
270        /// - Parameters:
271        /// - capability: The capability to be granted
272        /// - error: The error out param populated if the capability cannot be granted.
273        /// - invalidationHandler: The invalidation handler
274        ///
275        /// - Returns: an invalidatable grant object that represents the granted capability.
276        #[unsafe(method(grantCapability:error:invalidationHandler:))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn grantCapability_error_invalidationHandler(
279            &self,
280            capability: &BEProcessCapability,
281            error: Option<&mut Option<Retained<NSError>>>,
282            invalidation_handler: &block2::DynBlock<dyn Fn()>,
283        ) -> Option<Retained<ProtocolObject<dyn BEProcessCapabilityGrant>>>;
284    );
285}