objc2_background_assets/generated/
BAAssetPackManager.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    /// A class that manages asset packs.
12    ///
13    /// The first time that your code refers to the shared manager, Background Assets considers that your app is opting into automatic system management of your asset packs.
14    /// - Important: When using the asset-pack manager, make sure that you also adopt the corresponding managed extension protocol. For apps that use Apple hosting, the corresponding protocol is `SKDownloaderExtension` from StoreKit. For other apps, the corresponding protocol is ``BAManagedDownloaderExtension``. Not adopting the right protocol is a programmer error.
15    ///
16    /// See also [Apple's documentation](https://developer.apple.com/documentation/backgroundassets/baassetpackmanager?language=objc)
17    #[unsafe(super(NSObject))]
18    #[derive(Debug, PartialEq, Eq, Hash)]
19    pub struct BAAssetPackManager;
20);
21
22extern_conformance!(
23    unsafe impl NSObjectProtocol for BAAssetPackManager {}
24);
25
26impl BAAssetPackManager {
27    extern_methods!(
28        /// The shared asset-pack manager.
29        #[unsafe(method(sharedManager))]
30        #[unsafe(method_family = none)]
31        pub unsafe fn sharedManager() -> Retained<BAAssetPackManager>;
32
33        #[cfg(feature = "BAManagedAssetPackDownloadDelegate")]
34        /// An object that receives notifications about events that occur as an asset pack is downloaded.
35        #[unsafe(method(delegate))]
36        #[unsafe(method_family = none)]
37        pub unsafe fn delegate(
38            &self,
39        ) -> Option<Retained<ProtocolObject<dyn BAManagedAssetPackDownloadDelegate>>>;
40
41        #[cfg(feature = "BAManagedAssetPackDownloadDelegate")]
42        /// Setter for [`delegate`][Self::delegate].
43        ///
44        /// This is a [weak property][objc2::topics::weak_property].
45        #[unsafe(method(setDelegate:))]
46        #[unsafe(method_family = none)]
47        pub unsafe fn setDelegate(
48            &self,
49            delegate: Option<&ProtocolObject<dyn BAManagedAssetPackDownloadDelegate>>,
50        );
51
52        #[unsafe(method(init))]
53        #[unsafe(method_family = init)]
54        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
55
56        #[unsafe(method(new))]
57        #[unsafe(method_family = new)]
58        pub unsafe fn new() -> Retained<Self>;
59
60        #[cfg(all(feature = "BAAssetPack", feature = "block2"))]
61        /// Gets the asset packs that are available to download.
62        ///
63        /// This method might attempt to get the latest asset-pack information from the server.
64        /// - Parameter completionHandler: A block that receives the asset packs or an error if one occurs.
65        #[unsafe(method(getAllAssetPacksWithCompletionHandler:))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn getAllAssetPacksWithCompletionHandler(
68            &self,
69            completion_handler: &block2::DynBlock<dyn Fn(*mut NSSet<BAAssetPack>, *mut NSError)>,
70        );
71
72        #[cfg(all(feature = "BAAssetPack", feature = "block2"))]
73        /// Gets the asset pack with the given identifier.
74        ///
75        /// If no asset pack with the given identifier is found, then the block will receive an `NSError` object with ``BAManagedErrorCode/BAManagedErrorCodeAssetPackNotFound`` as its code for the `error` parameter. This method might attempt to get the latest asset-pack information from the server.
76        /// - Parameters:
77        /// - assetPackIdentifier: The asset pack’s identifier.
78        /// - completionHandler: A block that receives the asset pack or an error if one occurs.
79        #[unsafe(method(getAssetPackWithIdentifier:completionHandler:))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn getAssetPackWithIdentifier_completionHandler(
82            &self,
83            asset_pack_identifier: &NSString,
84            completion_handler: &block2::DynBlock<dyn Fn(*mut BAAssetPack, *mut NSError)>,
85        );
86
87        #[cfg(all(feature = "BAAssetPackStatus", feature = "block2"))]
88        /// Gets the status of the asset pack with the specified identifier.
89        ///
90        /// If no asset pack with the specified identifier is found, then the block will receive an `NSError` object with ``BAManagedErrorCode/BAManagedErrorCodeAssetPackNotFound`` as its code for the `error` parameter. This method attempts to get the latest asset-pack information from the server. No updates or removals are automatically triggered.
91        /// - Parameters:
92        /// - assetPackIdentifier: The asset pack’s identifier.
93        /// - completionHandler: A block that receives the status of the asset pack or an error if one occurs.
94        #[unsafe(method(getStatusOfAssetPackWithIdentifier:completionHandler:))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn getStatusOfAssetPackWithIdentifier_completionHandler(
97            &self,
98            asset_pack_identifier: &NSString,
99            completion_handler: &block2::DynBlock<dyn Fn(BAAssetPackStatus, *mut NSError)>,
100        );
101
102        #[cfg(all(feature = "BAAssetPack", feature = "block2"))]
103        /// Ensures that the specified asset pack be available locally.
104        ///
105        /// This method checks if the asset pack is currently downloaded. If it isn’t, then it schedules it to be downloaded and calls the block with `nil` for the block’s `error` parameter when the download completes. It’s guaranteed that the requested asset pack will be available locally once the block is called with `nil` for its `error` parameter. If a non-`nil` value is provided to the block’s `error` parameter, then the asset pack is **not** guaranteed to be available locally. You can optionally monitor download progress by attaching a delegate object to `delegate`.
106        /// - Parameters:
107        /// - assetPack: The asset pack the local availability of which to ensure.
108        /// - completionHandler: A block that’s called when the asset pack is available locally or that receives an error if one occurs.
109        #[unsafe(method(ensureLocalAvailabilityOfAssetPack:completionHandler:))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn ensureLocalAvailabilityOfAssetPack_completionHandler(
112            &self,
113            asset_pack: &BAAssetPack,
114            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
115        );
116
117        #[cfg(feature = "block2")]
118        /// Gets the latest asset-pack information from the server, updates outdated asset packs, and removes obsolete asset packs.
119        /// - Parameter completionHandler: A block that receives a set of identifiers of asset packs that are being updated and a set of identifiers of removed asset packs or an error if one occurs.
120        #[unsafe(method(checkForUpdatesWithCompletionHandler:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn checkForUpdatesWithCompletionHandler(
123            &self,
124            completion_handler: Option<
125                &block2::DynBlock<dyn Fn(*mut NSSet<NSString>, *mut NSSet<NSString>, *mut NSError)>,
126            >,
127        );
128
129        /// Returns the contents of an asset file at the specified relative path.
130        ///
131        /// All asset packs share the same namespace, so you can treat the overall collection of downloaded asset packs as if it were a single root directory that contains all of your subdirectories and asset files, regardless of the specific asset pack in which any particular file resides. If there’s a file-path collision across multiple asset packs, then it’s undefined from which asset pack the file will be read unless you explicitly limit the search to a particular asset pack by passing a non-`nil` identifier to the `assetPackIdentifier` parameter.
132        /// - Parameters:
133        /// - path: The relative file path.
134        /// - assetPackIdentifier: The identifier of the asset pack in which you want to search for the file or `nil` if you want to search in all asset packs.
135        /// - options: Options for how to read the contents of the file into a data object.
136        /// - error: A pointer to an error that will be set if an error occurs. If no file is found at `path`, then `error` will point to an `NSError` object with ``BAManagedErrorCode/BAManagedErrorCodeFileNotFound`` as its code.
137        /// - Returns: The file’s contents.
138        #[unsafe(method(contentsAtPath:searchingInAssetPackWithIdentifier:options:error:_))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn contentsAtPath_searchingInAssetPackWithIdentifier_options_error(
141            &self,
142            path: &NSString,
143            asset_pack_identifier: Option<&NSString>,
144            options: NSDataReadingOptions,
145        ) -> Result<Retained<NSData>, Retained<NSError>>;
146
147        /// Returns a URL for the specified relative path.
148        ///
149        /// All asset packs share the same namespace, so you can treat the overall collection of downloaded asset packs as if it were a single root directory that contains all of your subdirectories and asset files, regardless of the specific asset pack in which any particular file resides. Unlike ``BAAssetPackManager/contentsAtPath:searchingInAssetPackWithIdentifier:options:error:`` and ``BAAssetPackManager/fileDescriptorForPath:searchingInAssetPackWithIdentifier:error:``, this method supports retrieving entire directories—including packages—in which case it merges the corresponding slices of the shared logical directory from all downloaded asset packs that contain such slices. If there’s a file-path collision across multiple asset packs, then it’s undefined from which asset pack an individual file will be resolved.
150        /// - Parameters:
151        /// - path: The relative file path.
152        /// - error: A pointer to an error that will be set if an error occurs.
153        /// - Warning: Don’t persist the returned URL beyond the lifetime of the current process.
154        /// - Warning: This method is less efficient than are ``BAAssetPackManager/contentsAtPath:searchingInAssetPackWithIdentifier:options:error:`` and ``BAAssetPackManager/fileDescriptorForPath:searchingInAssetPackWithIdentifier:error:``; use those methods instead if you can do so. In particular, this method shouldn’t be used to get the URL to the root of the shared asset-pack namespace. Don’t use this method to block the main thread.
155        /// - Note: This method will return a well formed URL even if no item exists at the specified relative path in any asset pack, in which case any attempts to get its contents—whether it’s a file or a directory—will fail.
156        #[unsafe(method(URLForPath:error:_))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn URLForPath_error(
159            &self,
160            path: &NSString,
161        ) -> Result<Retained<NSURL>, Retained<NSError>>;
162
163        #[cfg(feature = "block2")]
164        /// Removes the specified asset pack from the device.
165        /// - Parameters:
166        /// - assetPackIdentifier: The asset pack’s identifier.
167        /// - completionHandler: A block that receives an error if one occurs.
168        #[unsafe(method(removeAssetPackWithIdentifier:completionHandler:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn removeAssetPackWithIdentifier_completionHandler(
171            &self,
172            asset_pack_identifier: &NSString,
173            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
174        );
175    );
176}