objc2_itunes_library/generated/
ITLibrary.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/// These constants describe the features supported by a given iTunes library.
11///
12/// No features are supported
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/ituneslibrary/itlibexportfeature?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct ITLibExportFeature(pub NSUInteger);
19impl ITLibExportFeature {
20    #[doc(alias = "ITLibExportFeatureNone")]
21    pub const None: Self = Self(0);
22}
23
24unsafe impl Encode for ITLibExportFeature {
25    const ENCODING: Encoding = NSUInteger::ENCODING;
26}
27
28unsafe impl RefEncode for ITLibExportFeature {
29    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32/// These constants describe the options that can be passed supported by a given iTunes library.
33///
34/// Load the library immediately on ITLibrary instance creation.
35///
36/// Don't load the library until the first request for data.
37///
38/// See also [Apple's documentation](https://developer.apple.com/documentation/ituneslibrary/itlibinitoptions?language=objc)
39// NS_ENUM
40#[repr(transparent)]
41#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
42pub struct ITLibInitOptions(pub NSUInteger);
43impl ITLibInitOptions {
44    #[doc(alias = "ITLibInitOptionNone")]
45    pub const None: Self = Self(0);
46    /// ITLibrary will be initialized but no iTunes library data will be loaded. Data will be lazy-loaded upon request.
47    #[doc(alias = "ITLibInitOptionLazyLoadData")]
48    pub const LazyLoadData: Self = Self(1);
49}
50
51unsafe impl Encode for ITLibInitOptions {
52    const ENCODING: Encoding = NSUInteger::ENCODING;
53}
54
55unsafe impl RefEncode for ITLibInitOptions {
56    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
57}
58
59extern "C" {
60    /// This notification is sent to NSDistributedNotificationCenter when a change has occurred in the library.
61    /// The client should call [ITLibrary -reloadData] if it wants a new view of the library contents.
62    ///
63    /// Note: This is not a fine-grained notification.  This API does not support per-object change notifications.
64    ///
65    /// See also [Apple's documentation](https://developer.apple.com/documentation/ituneslibrary/itlibrarydidchangenotification?language=objc)
66    pub static ITLibraryDidChangeNotification: &'static NSNotificationName;
67}
68
69extern_class!(
70    /// A class representing an iTunes library whose metadata is being queried.
71    ///
72    /// See also [Apple's documentation](https://developer.apple.com/documentation/ituneslibrary/itlibrary?language=objc)
73    #[unsafe(super(NSObject))]
74    #[derive(Debug, PartialEq, Eq, Hash)]
75    pub struct ITLibrary;
76);
77
78extern_conformance!(
79    unsafe impl NSObjectProtocol for ITLibrary {}
80);
81
82impl ITLibrary {
83    extern_methods!(
84        #[unsafe(method(init))]
85        #[unsafe(method_family = init)]
86        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
87
88        /// The version of iTunes being accessed.
89        #[unsafe(method(applicationVersion))]
90        #[unsafe(method_family = none)]
91        pub unsafe fn applicationVersion(&self) -> Retained<NSString>;
92
93        /// A bitwise OR combination of the features of this library.
94        #[unsafe(method(features))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn features(&self) -> ITLibExportFeature;
97
98        /// The major version number of this API.
99        #[unsafe(method(apiMajorVersion))]
100        #[unsafe(method_family = none)]
101        pub unsafe fn apiMajorVersion(&self) -> NSUInteger;
102
103        /// The minor version number of this API.
104        #[unsafe(method(apiMinorVersion))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn apiMinorVersion(&self) -> NSUInteger;
107
108        /// The location of the iTunes music folder.
109        #[unsafe(method(mediaFolderLocation))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn mediaFolderLocation(&self) -> Option<Retained<NSURL>>;
112
113        /// The location of the iTunes music folder. Replaced by mediaFolderLocation.
114        #[unsafe(method(musicFolderLocation))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn musicFolderLocation(&self) -> Option<Retained<NSURL>>;
117
118        /// Whether to show content rating labels.
119        #[unsafe(method(shouldShowContentRating))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn shouldShowContentRating(&self) -> bool;
122
123        #[cfg(all(feature = "ITLibMediaEntity", feature = "ITLibMediaItem"))]
124        /// All media items in the library.
125        #[unsafe(method(allMediaItems))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn allMediaItems(&self) -> Retained<NSArray<ITLibMediaItem>>;
128
129        #[cfg(all(feature = "ITLibMediaEntity", feature = "ITLibPlaylist"))]
130        /// All playlists in the library.
131        #[unsafe(method(allPlaylists))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn allPlaylists(&self) -> Retained<NSArray<ITLibPlaylist>>;
134
135        /// Creates and initializes an instance of ITLibrary which can be used to retrieve media entities.
136        ///
137        /// Upon initialization of the ITLibrary class, the default iTunes database for the current user will be read and parsed.
138        /// At this point all media entities will be cached in memory until the time the object is deallocated.
139        ///
140        /// Parameter `requestedAPIVersion`: The version of the iTunesLibrary API that the application is requesting, provide "1.0" if unknown.
141        ///
142        /// Parameter `error`: A pointer to a variable that will receive an NSError if this method fails. May be nil if caller does not care about error.
143        ///
144        /// Returns: An ITLibrary instance, or nil if this method fails.
145        #[unsafe(method(libraryWithAPIVersion:error:_))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn libraryWithAPIVersion_error(
148            requested_api_version: &NSString,
149        ) -> Result<Retained<Self>, Retained<NSError>>;
150
151        /// Creates and initializes an instance of ITLibrary which can be used to retrieve media entities.
152        ///
153        /// Unless the ITLibInitOptionLazyLoadData option is specified, the default iTunes database for the current user will be
154        /// read and parsed upon initialization of the ITLibrary class, and all media entities will be cached in memory.
155        ///
156        /// Parameter `requestedAPIVersion`: The version of the iTunesLibrary API that the application is requesting, provide "1.0" if unknown.
157        ///
158        /// Parameter `options`: Options that change the initialization behavior.
159        ///
160        /// Parameter `error`: A pointer to a variable that will receive an NSError if this method fails. May be nil if caller does not care about error.
161        ///
162        /// Returns: An ITLibrary instance, or nil if this method fails.
163        #[unsafe(method(libraryWithAPIVersion:options:error:_))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn libraryWithAPIVersion_options_error(
166            requested_api_version: &NSString,
167            options: ITLibInitOptions,
168        ) -> Result<Retained<Self>, Retained<NSError>>;
169
170        /// Initializes an instance of ITLibrary which can be used to retrieve media entities.
171        ///
172        /// Upon initialization of the ITLibrary class, the default iTunes database for the current user will be read and parsed.
173        /// At this point all media entities will be cached in memory until the time the object is deallocated.
174        ///
175        /// Parameter `requestedAPIVersion`: The version of the iTunesLibrary API that the application is requesting, provide "1.0" if unknown.
176        ///
177        /// Parameter `error`: A pointer to a variable that will receive an NSError if this method fails. May be nil if caller does not care about error.
178        ///
179        /// Returns: An ITLibrary instance, or nil if this method fails.
180        #[unsafe(method(initWithAPIVersion:error:_))]
181        #[unsafe(method_family = init)]
182        pub unsafe fn initWithAPIVersion_error(
183            this: Allocated<Self>,
184            requested_api_version: &NSString,
185        ) -> Result<Retained<Self>, Retained<NSError>>;
186
187        /// Initializes an instance of ITLibrary which can be used to retrieve media entities.
188        ///
189        /// Unless the ITLibInitOptionLazyLoadData option is specified, the default iTunes database for the current user will be
190        /// read and parsed upon initialization of the ITLibrary class, and all media entities will be cached in memory.
191        ///
192        /// Parameter `requestedAPIVersion`: The version of the iTunesLibrary API that the application is requesting, provide "1.0" if unknown.
193        ///
194        /// Parameter `options`: Options that change the initialization behavior.
195        ///
196        /// Parameter `error`: A pointer to a variable that will receive an NSError if this method fails. May be nil if caller does not care about error.
197        ///
198        /// Returns: An ITLibrary instance, or nil if this method fails.
199        #[unsafe(method(initWithAPIVersion:options:error:_))]
200        #[unsafe(method_family = init)]
201        pub unsafe fn initWithAPIVersion_options_error(
202            this: Allocated<Self>,
203            requested_api_version: &NSString,
204            options: ITLibInitOptions,
205        ) -> Result<Retained<Self>, Retained<NSError>>;
206
207        #[cfg(feature = "ITLibArtwork")]
208        /// Retrieves the artwork from a media file.
209        ///
210        /// Parameter `mediaFileURL`: The URL of the media file whose artwork should be extracted.
211        ///
212        /// Returns: A ITLibArtwork instance represeting the media file artwork, or nil if the artwork was not found or could not be extracted.
213        #[unsafe(method(artworkForMediaFile:))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn artworkForMediaFile(
216            &self,
217            media_file_url: &NSURL,
218        ) -> Option<Retained<ITLibArtwork>>;
219
220        /// Refreshes the data used by the framework.
221        ///
222        /// Returns: YES if the data was reloaded, false if an error occurred.
223        #[unsafe(method(reloadData))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn reloadData(&self) -> bool;
226
227        /// Unloads the data used by the framework.
228        #[unsafe(method(unloadData))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn unloadData(&self);
231    );
232}
233
234/// Methods declared on superclass `NSObject`.
235impl ITLibrary {
236    extern_methods!(
237        #[unsafe(method(new))]
238        #[unsafe(method_family = new)]
239        pub unsafe fn new() -> Retained<Self>;
240    );
241}