objc2_av_foundation/generated/AVExternalStorageDevice.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
10extern_class!(
11 /// An AVExternalStorageDevice represents a physical external storage device connected to the device that can be used to store captured media assets.
12 ///
13 ///
14 /// Each instance of AVExternalStorageDevice corresponds to a physical external storage device where captured media assets can be stored. Instances of AVExternalStorageDevice cannot be created directly. An array of all currently available external storage devices can be obtained using AVExternalStorageDeviceDiscoverySession.
15 ///
16 /// Instances of AVExternalStorageDevice can be used with AVCaptureFileOutput subclasses for writing media files.
17 ///
18 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avexternalstoragedevice?language=objc)
19 #[unsafe(super(NSObject))]
20 #[derive(Debug, PartialEq, Eq, Hash)]
21 pub struct AVExternalStorageDevice;
22);
23
24extern_conformance!(
25 unsafe impl NSObjectProtocol for AVExternalStorageDevice {}
26);
27
28impl AVExternalStorageDevice {
29 extern_methods!(
30 #[unsafe(method(init))]
31 #[unsafe(method_family = init)]
32 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
33
34 #[unsafe(method(new))]
35 #[unsafe(method_family = new)]
36 pub unsafe fn new() -> Retained<Self>;
37
38 /// Display name of the external storage device.
39 ///
40 ///
41 /// This property can be used for displaying the name of an external storage device in a user interface. Will return nil if we fail to extract information from external storage device.
42 #[unsafe(method(displayName))]
43 #[unsafe(method_family = none)]
44 pub unsafe fn displayName(&self) -> Option<Retained<NSString>>;
45
46 /// Current free size in bytes.
47 ///
48 ///
49 /// This property represents the free size available on the external storage device. Will return -1 if we fail to extract information from external storage device.
50 #[unsafe(method(freeSize))]
51 #[unsafe(method_family = none)]
52 pub unsafe fn freeSize(&self) -> NSInteger;
53
54 /// Total storage size in bytes.
55 ///
56 ///
57 /// This property represents the total storage size available on the external storage device. Will return -1 if we fail to extract information from external storage device.
58 #[unsafe(method(totalSize))]
59 #[unsafe(method_family = none)]
60 pub unsafe fn totalSize(&self) -> NSInteger;
61
62 /// Indicates whether the external storage device is connected and available to the system.
63 ///
64 ///
65 /// The property gives the current connection status of the external storage device.
66 #[unsafe(method(isConnected))]
67 #[unsafe(method_family = none)]
68 pub unsafe fn isConnected(&self) -> bool;
69
70 /// A unique identifier for external storage device.
71 ///
72 ///
73 /// This property can be used to select a specific external storage device with ImageCapture framework APIs to read media assets. Will return nil if we fail to extract information from external storage device.
74 /// For example the string value of this property will match the value from [ICDevice UUIDString].
75 #[unsafe(method(uuid))]
76 #[unsafe(method_family = none)]
77 pub unsafe fn uuid(&self) -> Option<Retained<NSUUID>>;
78
79 /// Indicates whether the external storage device is not recommended for capture use.
80 ///
81 ///
82 /// This property is used to let the client know if the external storage device is not suitable for camera capture.
83 #[unsafe(method(isNotRecommendedForCaptureUse))]
84 #[unsafe(method_family = none)]
85 pub unsafe fn isNotRecommendedForCaptureUse(&self) -> bool;
86
87 /// Next available security-scoped, DCF compliant URL array with different path extensions.
88 ///
89 ///
90 /// Parameter `extensionArray`: An array of path extensions for the next available URL requested.
91 ///
92 /// Parameter `outError`: An out parameter with error information indicating why the URL could not be provided. If this method is successful, error will be nil.
93 ///
94 /// Returns: An array of DCF compliant security-scoped URL with all the path extensions requested.
95 ///
96 ///
97 /// Configures the folder structure (create a DCIM folder if there isn't one already) on the external storage device to provide the next available unique DCF compliant security-scoped URL array with different path extensions.
98 ///
99 /// Security-scoped URL requires the use of startAccessingSecurityScopedResource, and stopAccessingSecurityScopedResource for access.
100 /// [nextAvailableURL startAccessingSecurityScopedResource];
101 /// . . .
102 /// // your code to capture image / video
103 /// . . .
104 /// [nextAvailableURL stopAccessingSecurityScopedResource];
105 ///
106 /// Use the +requestAccessWithCompletionHandler: method to request access to external storage device before getting the next available URL array else an error will be thrown.
107 #[unsafe(method(nextAvailableURLsWithPathExtensions:error:_))]
108 #[unsafe(method_family = none)]
109 pub unsafe fn nextAvailableURLsWithPathExtensions_error(
110 &self,
111 extension_array: &NSArray<NSString>,
112 ) -> Result<Retained<NSArray<NSURL>>, Retained<NSError>>;
113 );
114}
115
116/// AVExternalStorageDeviceAuthorization.
117impl AVExternalStorageDevice {
118 extern_methods!(
119 #[cfg(feature = "AVCaptureDevice")]
120 /// Returns the client's authorization status for capturing onto an external storage device connected to this device.
121 ///
122 ///
123 /// This method returns the AVAuthorizationStatus of the client for capturing onto an external storage device connected to this device. If the status is AVAuthorizationStatusNotDetermined, you may use the +requestAccessWithCompletionHandler: method to request access by prompting the user.
124 #[unsafe(method(authorizationStatus))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn authorizationStatus() -> AVAuthorizationStatus;
127
128 #[cfg(feature = "block2")]
129 /// Requests access to capture onto an external storage device connected to this device, showing a dialog to the user if necessary.
130 ///
131 ///
132 /// Parameter `handler`: A completion handler block called with the result of requesting access to capture onto an external storage device.
133 ///
134 ///
135 /// Use this method to request access to capture onto an external storage device connected to this device.
136 ///
137 /// This call will not block while the user is being asked for access, allowing the client to continue running. Until access has been granted, trying to capture into detected external storage devices will result in an error. The user is only asked for permission the first time the client requests access, later calls use the authorization status selected by the user.
138 ///
139 /// The completion handler is called on an arbitrary dispatch queue. It is the client's responsibility to ensure that any UIKit-related updates are called on the main queue or main thread as a result.
140 #[unsafe(method(requestAccessWithCompletionHandler:))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn requestAccessWithCompletionHandler(handler: &block2::DynBlock<dyn Fn(Bool)>);
143 );
144}
145
146extern_class!(
147 /// AVExternalStorageDeviceDiscoverySession is used to monitor connection / disconnection of external storage devices to the device.
148 ///
149 ///
150 /// AVExternalStorageDeviceDiscoverySession is a singleton that lists the external storage devices connected to this device. The client is expected to key-value observe the externalStorageDevices property for changes to the external storage devices list.
151 ///
152 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avexternalstoragedevicediscoverysession?language=objc)
153 #[unsafe(super(NSObject))]
154 #[derive(Debug, PartialEq, Eq, Hash)]
155 pub struct AVExternalStorageDeviceDiscoverySession;
156);
157
158extern_conformance!(
159 unsafe impl NSObjectProtocol for AVExternalStorageDeviceDiscoverySession {}
160);
161
162impl AVExternalStorageDeviceDiscoverySession {
163 extern_methods!(
164 #[unsafe(method(init))]
165 #[unsafe(method_family = init)]
166 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
167
168 #[unsafe(method(new))]
169 #[unsafe(method_family = new)]
170 pub unsafe fn new() -> Retained<Self>;
171
172 /// @
173 /// property sharedSession
174 ///
175 /// Returns the singleton instance of the external storage device discovery session.
176 ///
177 ///
178 /// There is only one external storage device discovery session for each host device which can be accessed using this method. Will return nil if the device doesn't support external storage devices.
179 #[unsafe(method(sharedSession))]
180 #[unsafe(method_family = none)]
181 pub unsafe fn sharedSession() -> Option<Retained<AVExternalStorageDeviceDiscoverySession>>;
182
183 /// An array of external storage devices connected to this device. Read only. Key-value observable.
184 ///
185 ///
186 /// An array of AVExternalStorageDevice objects connected to this device. The list is updated when the external storage device detected status changes.
187 #[unsafe(method(externalStorageDevices))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn externalStorageDevices(&self) -> Retained<NSArray<AVExternalStorageDevice>>;
190
191 /// Whether the external storage devices are supported by this device.
192 ///
193 ///
194 /// A value of YES indicates that external storage devices are supported while NO indicates it is not.
195 #[unsafe(method(isSupported))]
196 #[unsafe(method_family = none)]
197 pub unsafe fn isSupported() -> bool;
198 );
199}